srchilukoori opened a new pull request, #65742: URL: https://github.com/apache/airflow/pull/65742
## Description Migrates `DataprocSubmitTrigger` and `DataprocSubmitJobDirectTrigger` from the old `asyncio.CancelledError` cancellation pattern to the `BaseTrigger.on_kill()` hook introduced in #65590, as tracked in #65733. ## Changes **`providers/google/src/airflow/providers/google/cloud/triggers/dataproc.py`** For both `DataprocSubmitTrigger` and `DataprocSubmitJobDirectTrigger`: - Added `on_kill()` that cancels the Dataproc job via the sync hook wrapped in `sync_to_async` - Removed `safe_to_cancel()` — no longer needed; `on_kill()` fires exclusively on user-initiated kills, not on triggerer restarts or redistributions - Removed `get_task_state()` and the Airflow-2-compat `get_task_instance()` helpers — only used by `safe_to_cancel()` - Simplified `run()` by removing the `except asyncio.CancelledError` handler and the wrapping `try` block **`providers/google/tests/unit/google/cloud/triggers/test_dataproc.py`** Replaced the parametrised `safe_to_cancel` tests with focused `on_kill` tests: | Trigger | New tests | |---------|-----------| | `DataprocSubmitTrigger` | `test_on_kill_cancels_job`, `test_on_kill_respects_cancel_on_kill_false` | | `DataprocSubmitJobDirectTrigger` | `test_on_kill_cancels_job`, `test_on_kill_no_job_id_does_not_cancel`, `test_on_kill_respects_cancel_on_kill_false` | ## Root cause / motivation `BaseTrigger.on_kill()` was added specifically to replace the `CancelledError + safe_to_cancel()` pattern. The old approach required a task-instance state query to distinguish user kills from triggerer restarts; `on_kill()` makes that distinction at the framework level, so the triggers can be simplified. ## Checklist - [x] Tests pass (`4495 passed, 54 skipped` for the full `Providers[google]` suite) - [x] All pre-commit hooks pass --- > **AI Disclosure:** This PR was developed with the assistance of Claude (Anthropic). The implementation follows the reference pattern from #65672 (Databricks triggers). All logic, tests, and decisions were reviewed by the contributor. -- 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]
