Skip to content

Commit cadc7e5

Browse files
committed
Add prefix to Hadoop properties if it does not start with 'spark.hadoop.'
Signed-off-by: Yi Chen <[email protected]>
1 parent 544da9b commit cadc7e5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

internal/controller/sparkconnect/options.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package sparkconnect
1818

1919
import (
2020
"fmt"
21+
"strings"
2122

2223
"github.com/kubeflow/spark-operator/v2/api/v1alpha1"
2324
"github.com/kubeflow/spark-operator/v2/pkg/common"
@@ -129,7 +130,13 @@ func hadoopConfOption(conn *v1alpha1.SparkConnect) ([]string, error) {
129130
var args []string
130131
// Add Hadoop configuration properties.
131132
for key, value := range conn.Spec.HadoopConf {
132-
args = append(args, "--conf", fmt.Sprintf("spark.hadoop.%s=%s", key, value))
133+
if strings.HasPrefix(key, common.SparkHadoopPropertiesPrefix) {
134+
args = append(args, "--conf", fmt.Sprintf("%s=%s", key, value))
135+
} else {
136+
// Add prefix to the configuration key if it does not start with `spark.hadoop.`.
137+
// Users will be able to use the configuration key with or without prefix.
138+
args = append(args, "--conf", fmt.Sprintf("%s%s=%s", common.SparkHadoopPropertiesPrefix, key, value))
139+
}
133140
}
134141
return args, nil
135142
}

pkg/common/spark.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ const (
279279
// This directory is where the Hadoop ConfigMap is mounted in the driver and executor containers.
280280
DefaultHadoopConfDir = "/etc/hadoop/conf"
281281

282+
// SparkHadoopPropertiesPrefix is the prefix of the Spark configuration keys for Hadoop properties.
283+
SparkHadoopPropertiesPrefix = "spark.hadoop."
284+
282285
// HadoopConfigMapVolumeName is the name of the ConfigMap volume of Hadoop configuration files.
283286
HadoopConfigMapVolumeName = "hadoop-configmap-volume"
284287

0 commit comments

Comments
 (0)