Vamsi-klu opened a new pull request, #67050:
URL: https://github.com/apache/airflow/pull/67050

   In deferrable mode, `CloudRunExecuteJobOperator` was reporting task success
   even when the underlying Cloud Run Job was cancelled mid-run. The sync path
   guards against this in `_fail_if_execution_failed` by checking that
   `succeeded_count + failed_count == task_count` on the returned `Execution`,
   but `CloudRunJobFinishedTrigger` only inspected `operation.done` and
   `operation.error`. A user-initiated cancel from the Google Cloud UI/API
   completes the LRO without populating `operation.error`, so the trigger
   yielded `SUCCESS` and `execute_complete` happily fetched the Job and
   returned.
   
   Fix: when the LRO is done with no `operation.error`, deserialize the
   `Execution` from `operation.response` and apply the same count check the
   sync path uses, yielding `FAIL` with a descriptive message when the
   counts indicate cancellation or partial completion. The operator already
   raises `AirflowException` on `FAIL` events, so no operator change is
   needed.
   
   closes: #57791
   
   ## Tests
   
   - New `test_trigger_yields_fail_when_job_cancelled` — LRO done, no
     `operation.error`, `Execution` has `task_count=3, succeeded_count=1,
     cancelled_count=2`; assert `FAIL` event with a message mentioning
     cancellation and the cancelled count.
   - New `test_trigger_yields_fail_when_some_tasks_failed` — symmetry guard
     against the sync path's `failed_count > 0` branch.
   - Updated existing success test to provide a real packed `Execution`
     proto in `operation.response` so the new deserialization path is
     exercised.
   - New `test_execute_deferrable_execute_complete_method_fail_on_cancellation`
     pins the operator-level contract that a cancellation-shaped `FAIL`
     event propagates as `AirflowException`.
   
   All 6 trigger tests and 31 operator tests pass locally:
   `uv run --project providers/google pytest 
providers/google/tests/unit/google/cloud/triggers/test_cloud_run.py 
providers/google/tests/unit/google/cloud/operators/test_cloud_run.py -xvs`
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7)
   
   Generated-by: Claude Code (Opus 4.7) 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]

Reply via email to