You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/09/22 18:54:11 UTC
[GitHub] [airflow] jvstein edited a comment on issue #8792: KubernetesPodOperator does not return XCOM on pod failure
jvstein edited a comment on issue #8792:
URL: https://github.com/apache/airflow/issues/8792#issuecomment-696914010
@Shivarp1 - I have not tested in Airflow 1.10.12. Reading through the [relevant section on the 1.10.12 tag](https://github.com/apache/airflow/blob/1.10.12/airflow/contrib/operators/kubernetes_pod_operator.py#L280-L288), I suspect the same issue exists.
I just noticed that my repro steps had a bug in the command. It should have been `exit 1` not `echo 1` at the end. I updated the description.
We're currently using 1.10.9, with the following patch.
```
diff --git c/airflow/contrib/operators/kubernetes_pod_operator.py i/airflow/contrib/operators/kubernetes_pod_operator.py
index f692599d7..f4b970d7e 100644
--- c/airflow/contrib/operators/kubernetes_pod_operator.py
+++ i/airflow/contrib/operators/kubernetes_pod_operator.py
@@ -20,6 +20,7 @@ import warnings
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
+from airflow.models import XCOM_RETURN_KEY
from airflow.utils.decorators import apply_defaults
from airflow.contrib.kubernetes import kube_client, pod_generator, pod_launcher
from airflow.contrib.kubernetes.pod import Resources
@@ -253,12 +254,13 @@ class KubernetesPodOperator(BaseOperator): # pylint: disable=too-many-instance-
if self.is_delete_operator_pod:
launcher.delete_pod(pod)
+ if self.do_xcom_push:
+ self.xcom_push(context, XCOM_RETURN_KEY, result)
+
if final_state != State.SUCCESS:
raise AirflowException(
'Pod returned a failure: {state}'.format(state=final_state)
)
- if self.do_xcom_push:
- return result
except AirflowException as ex:
raise AirflowException('Pod Launching failed: {error}'.format(error=ex))
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org