Skip to content

Commit f8a83a7

Browse files
committed
[AIRFLOW-6949] Respect explicit spark.kubernetes.namespace conf to SparkSubmitOperator (#7575)
This means the value from the Operator/dag file takes precedence over the connection The previous behaviour was to emit one line from the conf arg, but then a later one from the connection: ``` --conf spark.kubernetes.namespace=airflow \ --conf spark.kubernetes.namespace=default \ ``` (cherry picked from commit b59042b)
1 parent 2f818f1 commit f8a83a7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

airflow/contrib/hooks/spark_submit_hook.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(self,
126126
env_vars=None,
127127
verbose=False,
128128
spark_binary=None):
129-
self._conf = conf
129+
self._conf = conf or {}
130130
self._conn_id = conn_id
131131
self._files = files
132132
self._py_files = py_files
@@ -248,9 +248,11 @@ def _build_spark_submit_command(self, application):
248248
# The url of the spark master
249249
connection_cmd += ["--master", self._connection['master']]
250250

251-
if self._conf:
252-
for key in self._conf:
253-
connection_cmd += ["--conf", "{}={}".format(key, str(self._conf[key]))]
251+
if 'spark.kubernetes.namespace' in self._conf:
252+
conn_data['namespace'] = self._conf['spark.kubernetes.namespace']
253+
254+
for key in self._conf:
255+
connection_cmd += ["--conf", "{}={}".format(key, str(self._conf[key]))]
254256
if self._env_vars and (self._is_kubernetes or self._is_yarn):
255257
if self._is_yarn:
256258
tmpl = "spark.yarn.appMasterEnv.{}={}"

0 commit comments

Comments
 (0)