zshubai opened a new pull request, #77881:
URL: https://github.com/apache/airflow/pull/77881

   Killing a `CloudRunExecuteJobOperator` task (mark failed, clear or mark 
success) now cancels its Cloud Run job execution, in deferrable and 
non-deferrable mode. Until now the execution kept running, and clearing a 
running task started a second execution next to the first.
   
   ### Notes for reviewers
   
   - This is on by default: `cancel_on_kill=True`, as in the BigQuery, Dataproc 
and Dataflow operators. It also applies to mark success. `cancel_on_kill=False` 
keeps the old behaviour.
   - Deferred tasks are cancelled from the trigger's `on_kill`. Airflow calls 
it only on 3.3+ and only when a user acts on the task, not on a triggerer 
restart or a trigger timeout. On older Airflow versions deferred tasks behave 
as before; non-deferrable tasks are cancelled on all versions.
   - A trigger serialized by an older provider version has no `execution_name`. 
The trigger then reads it from the operation and does nothing if the operation 
has finished.
   - Cancelling needs the `run.executions.cancel` permission, which 
`roles/run.jobsExecutor`, `roles/run.jobsExecutorWithOverrides` and 
`roles/run.developer` include.
   
   ### End to end verification
   
   Tested against a Cloud Run job that prints a timestamp every second, killing 
the task with "Mark as failed":
   
   | Case | Without this PR | With this PR |
   |---|---|---|
   | Deferrable | execution keeps running | cancelled about 20 s after the kill 
|
   | Non-deferrable | execution keeps running | cancelled about 20 s after the 
kill |
   | Deferrable, `cancel_on_kill=False` | option not available | execution 
keeps running |
   
   The 17 new unit test cases fail without the change.
   
   related: #36090
   related: #76320
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes, Claude Code (Opus 5.5)
   
   Generated-by: Claude Code (Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] Cancel the Cloud Run job ... zshubai (via GitHub) via commits

Reply via email to