Skip to content

Commit

Permalink
[AIRFLOW-6506] Fix do_xcom_push defaulting to True in KubernetesPodOp…
Browse files Browse the repository at this point in the history
…erator (#7122)

(cherry-picked from 86f525f)
  • Loading branch information
dimberman authored and kaxil committed Jan 23, 2020
1 parent adb409f commit 302fa5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions airflow/contrib/operators/kubernetes_pod_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __init__(self, # pylint: disable=too-many-arguments,too-many-locals
security_context=None,
pod_runtime_info_envs=None,
dnspolicy=None,
do_xcom_push=False,
*args,
**kwargs):
# https://github.com/apache/airflow/blob/2d0eff4ee4fafcf8c7978ac287a8fb968e56605f/UPDATING.md#unification-of-do_xcom_push-flag
Expand All @@ -156,6 +157,7 @@ def __init__(self, # pylint: disable=too-many-arguments,too-many-locals
DeprecationWarning, stacklevel=2
)
super(KubernetesPodOperator, self).__init__(*args, resources=None, **kwargs)
self.do_xcom_push = do_xcom_push
self.image = image
self.namespace = namespace
self.cmds = cmds or []
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/kubernetes/test_kubernetes_pod_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ def setUp(self):
}
}

def test_do_xcom_push_defaults_false(self):
new_config_path = '/tmp/kube_config'
old_config_path = os.path.expanduser('~/.kube/config')
shutil.copy(old_config_path, new_config_path)

k = KubernetesPodOperator(
namespace='default',
image="ubuntu:16.04",
cmds=["bash", "-cx"],
arguments=["echo 10"],
labels={"foo": "bar"},
name="test",
task_id="task",
in_cluster=False,
do_xcom_push=False,
config_file=new_config_path,
)
self.assertFalse(k.do_xcom_push)

def test_config_path_move(self):
new_config_path = '/tmp/kube_config'
old_config_path = os.path.expanduser('~/.kube/config')
Expand Down

0 comments on commit 302fa5b

Please sign in to comment.