Skip to content

[airflow-ctl/v0-1-test] airflow-ctl-tests: wait for Dag run terminal state before xcom commands (#67065) - #75752

Merged
shahar1 merged 1 commit into
apache:airflow-ctl/v0-1-testfrom
Andrushika:backport-977935d-airflow-ctl/v0-1-test
Oct 27, 2026
Merged

shahar1 merged 1 commit into
apache:airflow-ctl/v0-1-testfrom
Andrushika:backport-977935d-airflow-ctl/v0-1-test

Conversation

@Andrushika

Copy link
Copy Markdown
Contributor

Why

The airflowctl integration tests add an XCom right after dags trigger. When the task starts, the execution API clears all XComs of that task instance. If the task starts after the test adds the XCom, the next xcom edit or xcom delete fails with "XCom doesn't exist". #67065 fixed this on main, but airflow-ctl/v0-1-test does not have the fix. I saw these steps fail in my runs for #57826.

What

Clean cherry-pick of #67065. The tests now wait for the Dag run to reach a terminal state before the xcom commands. #72260 builds on this change, and I will backport it after this one.

related: #57826


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

…state before xcom commands (apache#67065)

The airflowctl xcom integration tests are flaky on ARM CI: xcom add plus
xcom get and xcom list succeed, then xcom edit and xcom delete fail with
"The XCom with key ... doesn't exist". Same SHA passes on some ARM runs
and fails on others.

Root cause is a race between the test's xcom add and execution of
runme_0. When the task transitions to RUNNING, the execution API
queries every XCom key for that task instance and tells the worker to
clear them via xcom_keys_to_clear (see
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py
and task-sdk/src/airflow/sdk/execution_time/task_runner.py). If the
xcom add lands before the task starts running -- which only takes a
few seconds for the bash echo task in example_bash_operator -- the
user-added XCom is wiped right before xcom edit / xcom delete fires.

Wait for the targeted Dag run to reach a terminal state before each
xcom command. Once the task is terminal it won't run again, so the
clear logic doesn't fire and the user-added XCom survives the rest of
the xcom commands.

(cherry picked from commit 977935d)
@shahar1
shahar1 merged commit c3151cb into apache:airflow-ctl/v0-1-test Oct 27, 2026
13 checks passed
@Andrushika
Andrushika deleted the backport-977935d-airflow-ctl/v0-1-test branch October 27, 2026 13:38
shahar1 pushed a commit that referenced this pull request Nov 19, 2026
…state before xcom commands (#67065) (#75752)

The airflowctl xcom integration tests are flaky on ARM CI: xcom add plus
xcom get and xcom list succeed, then xcom edit and xcom delete fail with
"The XCom with key ... doesn't exist". Same SHA passes on some ARM runs
and fails on others.

Root cause is a race between the test's xcom add and execution of
runme_0. When the task transitions to RUNNING, the execution API
queries every XCom key for that task instance and tells the worker to
clear them via xcom_keys_to_clear (see
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py
and task-sdk/src/airflow/sdk/execution_time/task_runner.py). If the
xcom add lands before the task starts running -- which only takes a
few seconds for the bash echo task in example_bash_operator -- the
user-added XCom is wiped right before xcom edit / xcom delete fires.

Wait for the targeted Dag run to reach a terminal state before each
xcom command. Once the task is terminal it won't run again, so the
clear logic doesn't fire and the user-added XCom survives the rest of
the xcom commands.

(cherry picked from commit 977935d)

Co-authored-by: Jarek Potiuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants