Skip to content

Fix GKEStartPodOperator ignoring execution_timeout when deferrable - #71528

Merged
shahar1 merged 3 commits into
apache:mainfrom
AyushkhatiDev:fix/gke-execution-timeout
Oct 18, 2026
Merged

shahar1 merged 3 commits into
apache:mainfrom
AyushkhatiDev:fix/gke-execution-timeout

Conversation

@AyushkhatiDev

Copy link
Copy Markdown
Contributor

Summary

Fixes #71514.

GKEStartPodOperator did not respect execution_timeout when
deferrable=True because its custom invoke_defer_method did not
propagate the execution deadline to GKEStartPodTrigger.

What changed

  • Translate execution_timeout into an absolute _execution_deadline
    anchored to the task instance start_date.
  • Pass the deadline through trigger_kwargs to GKEStartPodTrigger.
  • Add a buffered defer.timeout backstop so the trigger can emit its
    timeout event before the framework timeout fires.
  • Preserve trigger_kwargs in GKEStartPodTrigger.serialize() so the
    deadline survives trigger serialization/restarts.
  • Add regression tests covering deadline propagation, no-timeout
    behavior, existing trigger_kwargs, and trigger serialization.

Testing

  • TestGKEStartPodOperator: 16 passed
  • GKEStartPodTrigger serialization test: passed
  • Ruff format/check: passed

One broader trigger test run encountered an unrelated local
ModuleNotFoundError: airflow_shared in the test infrastructure.
The affected serialization test and all operator tests for this change
passed successfully.

@AyushkhatiDev
AyushkhatiDev requested a review from shahar1 as a code owner August 13, 2026 05:22
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Aug 13, 2026
@boring-cyborg

boring-cyborg Bot commented Aug 13, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@shahar1 shahar1 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review

The fix looks right: it mirrors the deferrable KubernetesPodOperator change from #67229. GKEStartPodTrigger inherits the deadline handling from KubernetesPodTrigger, the inherited trigger_reentry already handles status="timeout", and adding trigger_kwargs to serialize() keeps the deadline across triggerer restarts. There is also a useful side effect: user-supplied trigger_kwargs and the re-defer counter (_redefer_count) now reach the GKE trigger, which was not the case before. I have left a few test-related comments inline (on test_kubernetes_engine.py:1077 and :1085). None of them is blocking. The earlier request to trim the comments has been addressed.

Smaller observations

  • Minimum cncf.kubernetes version. The trigger-side timeout only works with apache-airflow-providers-cncf-kubernetes>=10.18.0, the first release that contains #67229. The Google provider's cncf.kubernetes extra still declares >=10.1.0. With versions 10.6–10.17, the trigger ignores _execution_deadline, so only the defer(timeout=...) backstop fires. The task then fails through the deferral-timeout path, and the pod is not cleaned up. This is still better than running forever, and you should not change the floor in this PR (per providers/AGENTS.md, only release managers raise >= floors). I am mentioning it so the release manager can see it.
  • Unspecced mocks. In the new tests, ti is a bare mock.MagicMock() (:1105, :1150, :1191). AGENTS.md says: "Use spec/autospec when mocking." mock.MagicMock(spec=["start_date"]) would be enough here.
  • Gen-AI disclosure. The PR description replaces the repository's PR template, which removes the "Was generative AI tooling used to co-author this PR?" section. Please restore that section and tick it if it applies. See Gen-AI Assisted contributions.

Worth a second look from

This change mirrors the cncf.kubernetes deferrable-timeout logic. These people have the most context on it:

  • @jscheffl — CODEOWNERS owner for providers/cncf/kubernetes (committer); approved #67229
  • @paultmathew — authored #67229, the KPO change this PR ports

None of them have been notified. Asking any of them for an extra pass is the maintainer's call, and optional.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The findings
below are observations, not blockers; an Apache Airflow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.

More on how Apache Airflow handles maintainer review:
contributing-docs/05_pull_requests.rst.

@VladaZakharova VladaZakharova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question regarding scope: since GKEStartPodOperator extends KubernetesPodOperator, does this issue also affect standard KPO when deferrable=True? If so, should this logic live in the underlying cncf.kubernetes trigger/operator so both benefit from the fix, or is this specific to GKE's hook/trigger implementation?

Ayushkhatidev and others added 3 commits October 18, 2026 10:16
Parametrize the three invoke_defer_method execution_timeout tests, import
time_machine at module level, spec the task instance mock, and cover the
poll-interval buffer, the clamp once the deadline has passed, the
no-context guard, and that the operator's own trigger_kwargs are not
mutated.
@shahar1
shahar1 force-pushed the fix/gke-execution-timeout branch from 3be953d to 76483a0 Compare October 18, 2026 07:22
@shahar1
shahar1 merged commit 34ffab8 into apache:main Oct 18, 2026
87 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 18, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GKEStartPodOperator does not respect execution_timeout when deferrable=True

4 participants