You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate EmrServerlessStartJobTrigger from the old asyncio.CancelledError
catch pattern to the new BaseTrigger.on_kill() hook (added via apache#65590).
Changes:
- Add async on_kill() method that cancels the EMR Serverless job
only on user-initiated task kills
- Remove the CancelledError handler from run(), letting the parent
class AwsBaseWaiterTrigger.run() handle the standard waiter flow
- Remove safe_to_cancel(), get_task_instance(), get_task_state()
which are no longer needed (on_kill only fires on user kills)
- Clean up unused imports (asyncio, AIRFLOW_V_3_0_PLUS,
TaskInstanceState, etc.)
- Update tests to directly verify on_kill() behavior
Closes: apache#65733 (EmrServerlessStartJobTrigger part)
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.
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
We do want to keep the existing code for now for compatibility reasons. BaseTrigger.on_kill() will be part of Airflow 3.3 but the provider must be working with previous versions as well
…hook
Address review feedback from vincbeck: keep the existing
CancelledError handler in run() and safe_to_cancel() logic for
backward compatibility with Airflow < 3.3. Add on_kill() as an
additional cancellation path for Airflow 3.3+ where
BaseTrigger.on_kill() is available.
Changes:
- Restore all original code (run(), safe_to_cancel(),
get_task_instance(), get_task_state())
- Add async on_kill() that fires on user-initiated kills (3.3+)
- Add tests for on_kill() behavior
@vincbeck Thanks for pointing that out! Totally makes sense — I didn't consider that the provider needs to work with older Airflow versions too. I've updated the PR to keep all the existing code as-is and just added on_kill() on top. The diff is now purely additive. Let me know if anything else needs changing!
The reason will be displayed to describe this comment to others. Learn more.
One nit: can you add a comment saying that the old way (using CancelledError) can be removed once the min Airflow version supported by provider is >= 3.3
CI caught a minor ruff/pre-commit formatting discrepancy with the docstring style and line spacing. Just pushed the auto-formatted fixes, so the static checks should all run green now!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate
EmrServerlessStartJobTriggerfrom the oldasyncio.CancelledErrorcatch pattern to the newBaseTrigger.on_kill()hook (added via #65590).Changes:
async on_kill()method that cancels the EMR Serverless job only on user-initiated task killsCancelledErrorhandler fromrun(), letting the parent classAwsBaseWaiterTrigger.run()handle the standard waiter flowsafe_to_cancel(),get_task_instance(),get_task_state()which are no longer needed (on_killonly fires on user kills)asyncio,AIRFLOW_V_3_0_PLUS,TaskInstanceState, etc.)on_kill()behaviorFollows the same pattern as the Databricks trigger migration in #65590.
Was generative AI tooling used to co-author this PR?
Generated-by: Gemini following the guidelines