Add on_kill() to DatabricksTaskBaseOperator to cancel runs on task kill#69442
Open
victorymakes wants to merge 4 commits into
Open
Add on_kill() to DatabricksTaskBaseOperator to cancel runs on task kill#69442victorymakes wants to merge 4 commits into
victorymakes wants to merge 4 commits into
Conversation
DatabricksSubmitRunOperator and DatabricksRunNowOperator both implement on_kill() to cancel the Databricks run when an Airflow task is killed. DatabricksTaskBaseOperator — used by DatabricksTaskOperator and DatabricksNotebookOperator — is missing the same implementation, so Databricks jobs continue running after the Airflow task is killed, orphaning compute resources. DatabricksWorkflowTaskGroup received on_kill() in apache#42115; this PR closes the remaining gap for standalone task operators. Uses self.databricks_run_id which is initialised to None in __init__ and set by _launch_job() the moment the run is submitted.
…rator (ruff format)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
DatabricksSubmitRunOperatorandDatabricksRunNowOperatorboth implementon_kill()to cancel the Databricks run when an Airflow task is killed (SIGTERM orexecution_timeout).DatabricksTaskBaseOperator— the base forDatabricksTaskOperatorandDatabricksNotebookOperator— is missing the same implementation, so Databricks jobs continue running after the Airflow task is killed, orphaning compute resources and incurring unnecessary cloud spend.DatabricksWorkflowTaskGroupreceivedon_kill()in #42115; this PR closes the remaining gap for standalone task operators.Changes
on_kill()toDatabricksTaskBaseOperatorusingself.databricks_run_id, which is:Nonein__init__(noAttributeErrorrisk)_launch_job()the moment the run is submitted — earlier than any polling or permission callsTesting
Was generative AI tooling used to co-author this PR?