avanish-garg opened a new pull request, #72378:
URL: https://github.com/apache/airflow/pull/72378
Fixes #36516
## Problem
Nothing observes a Dag's `is_paused` transitions today. Listener plugins can
react to DagRun state
changes (`on_dag_run_running`/`success`/`failed`) but there's no equivalent
for a Dag being
paused/unpaused, even though that's one of the highest-consequence single
actions a user can take
on a Dag (it stops all future scheduling) and is exactly the kind of thing
multi-team deployments
want to audit.
## Change
- New `on_dag_pause_status_change(dag: DagModel, is_paused: bool)` hookspec
in a new
`airflow/listeners/spec/dag.py`, registered in `listeners/listener.py`
alongside the existing
`dagrun`/`taskinstance`/`asset`/`importerrors` specs.
- Fired from `patch_dag()` in `api_fastapi/core_api/routes/public/dags.py`
when `is_paused` is
part of the patch and actually changes value.
- Fired from `set_is_paused()` in `cli/commands/dag_command.py` (backing
`airflow dags
pause`/`unpause`) for each Dag whose `is_paused` actually changes — the
query already filters to
only Dags where the value differs, so no extra no-op check needed there.
- Docs: new "Dag Pause Status Events" section in
`administration-and-deployment/listeners.rst`,
plus a runnable example in `example_dags/plugins/event_listener.py`.
- Tests covering both call sites, including that re-setting the same value
doesn't re-fire the
hook.
## Out of scope for this PR
The scheduler's `max_consecutive_failed_dag_runs` circuit breaker also sets
`is_paused` (via a
bulk `UPDATE` in `DagRun._check_last_n_dagruns_failed`), but doesn't load a
`DagModel` instance to
fire a hook from, and folding it in cleanly needs a bit more restructuring
than this PR's scope.
Flagged in the issue; happy to follow up separately if there's interest.
--
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]