问题
created an image contain /airflow/xcom/return.json
with chmod +x on all sub-dir
Since the log show it cannot find file or directory(tried chmod +x)
strtpodbefore = KubernetesPodOperator(namespace='rguonew',
image="mydockerimage",
name="fail",
image_pull_policy="Always",
task_id="failing-task",
get_logs= True,
xcom_push=True,
dag=dag
)'
Here is the log
[2019-03-18 20:32:07,007] {logging_mixin.py:95} INFO - [2019-03-18
20:32:07,007] {pod_launcher.py:166} INFO - Running command... cat
/airflow/xcom/return.json
[2019-03-18 20:32:07,007] {logging_mixin.py:95} INFO -
[2019-03-18 20:32:07,026] {logging_mixin.py:95} INFO - [2019-03-18
20:32:07,026] {pod_launcher.py:173} INFO - cat: can't open
'/airflow/xcom/return.json': No such file or directory
[2019-03-18 20:32:07,026] {logging_mixin.py:95} INFO -
[2019-03-18 20:32:07,026] {logging_mixin.py:95} INFO - [2019-03-18
20:32:07,026] {pod_launcher.py:166} INFO - Running command... kill -s
SIGINT 1
[2019-03-18 20:32:07,026] {logging_mixin.py:95} INFO -
[2019-03-18 20:32:07,067] {models.py:1788} ERROR - Pod Launching
failed: Failed to extract xcom from pod: fail-e18e3dac
So tried with this way it works, but it means its assigns the xcom json from outside but not from the image
return_value = '{"foo": "bar"\n, "buzz": 2}'
strtpodbefore = KubernetesPodOperator(namespace='rguonew',
image="python:3.6.6-stretch",
cmds=["bash", "-cx"],
name="fail",
task_id="failing-task",
arguments=['echo \'{}\' >
/airflow/xcom/return.json'.format(return_value)],
get_logs= True,
xcom_push=True,
dag=dag
)
so i tried the final solution with doing an extra argument but still doesnt work, the first command get no such directory return
strtpodbefore = KubernetesPodOperator(namespace='rguonew',
image="myimages",
name="fail",
image_pull_policy="Always",
cmds=["bash", "-cx"],
arguments=['echo \'{}\' >
/airflow/xcom/return.json'.format(return_value)],
task_id="failing-task",
get_logs= True,
xcom_push=True,
dag=dag
)
回答1:
When you set the xcom_push=True, a sidecar container will be created along with your executor container. The sidecar container will read the executor's /airflow/xcom/return.json
, so you actually need to write to this from the executor container as you have done in the 2nd example.
See here: https://stackoverflow.com/a/53568710/10675601
When we were working on our pod xcom, there were also some issues related to RBAC that you need to set: Airflow k8s operator xcom - Handshake status 403 Forbidden
来源:https://stackoverflow.com/questions/55230150/no-such-file-or-directory-airflow-xcom-return-json