KubernetesPodOperator does not return XCOM on pod failure
See original GitHub issueApache Airflow version: 1.10.9
Kubernetes version (if you are using kubernetes) (use kubectl version
): 1.14.9
Environment:
- Cloud provider or hardware configuration: AWS EKS
- OS (e.g. from /etc/os-release): Linux (debian 9.12 inside docker image)
- Kernel (e.g.
uname -a
): 5.4.0 (on my host) - Install tools:
- Others:
What happened:
I ran a new task using the KubernetesPodOperator
on our k8s cluster. This pod is designed to write to the /airflow/xcom/return.json
even in case of failures so we can send a user-friendly error message in a following task. The pod exits with a non-zero exit code, so Airflow appropriately updates the task as failed, but the XCOM values are not available.
What you expected to happen:
I expected XCOM variables to be available even on pod failure. We use this capability in other operators to signal error conditions and messages.
How to reproduce it:
Run a KubernetesPodOperator with a command like this in an alpine image.
/bin/bash -c 'echo "{'success': False}" > /airflow/xcom/return.json; exit 1'
Check the XCOM results, which should include the JSON dictionary.
Anything else we need to know:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top GitHub Comments
Yeah I think we should go ahead and make this with no option – just make it push xcom in a
finally
or something. But have to check on timing. There’s a refactor of KPO in progress and may make sense to include the change as part of that.@Shivarp1 - I have not tested in Airflow 1.10.12. Reading through the relevant section on the 1.10.12 tag, 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
notecho 1
at the end. I updated the description.We’re currently using 1.10.9, with the following patch.