Anurag-S1ngh opened a new pull request, #77086:
URL: https://github.com/apache/airflow/pull/77086

   ## Summary
   A trigger that recorded failures is no longer deleted the moment nothing 
references it. It is marked `finished` and released from its triggerer so it 
never runs again, and deleted once it has been finished for `[triggerer] 
failed_trigger_retention` seconds (default 7 days). Triggers that never failed 
are still deleted right away. The API lists finished triggers with their own 
status.
   
   ## Changes
   - New `finished_at` column on `trigger` (migration 0157)
   - New `finished` `TriggerStatus`; `status_expression()` and `status()` 
report it; `kind_expression()`/`kind` recognize the watcher marker recorded at 
finish time
   - Both cleanups (`Trigger.clean_unused` and scheduler 
`_remove_unreferenced_triggers`) mark unreferenced failed triggers finished, 
and delete only never-failed triggers or finished triggers older than the 
retention
   - Finished triggers are never re-assigned (all three `get_sorted_triggers` 
queries and `ids_for_triggerer` exclude them); a finished trigger that regains 
a reference is resurrected on the next assignment pass
   - API: finished triggers are included in `GET /triggers` and `GET 
/triggers/{id}`, the response carries `finished_at`, and `TriggerStatus` gained 
`finished` (openapi spec, airflow-ctl and UI codegen updated)
   - New config `[triggerer] failed_trigger_retention` (default 604800 seconds, 
set to 0 to delete failed triggers as soon as they become unreferenced)
   
   ## Testing
   - `uv run --project airflow-core pytest 
airflow-core/tests/unit/models/test_trigger.py -q` (107 passed)
   - `uv run --project airflow-core pytest 
airflow-core/tests/unit/migrations/test_0157_add_finished_at_to_trigger.py -q` 
(2 passed)
   - `uv run --project airflow-core pytest 
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_triggers.py -q` 
(54 passed)
   - `uv run --project airflow-core pytest 
airflow-core/tests/unit/jobs/test_scheduler_job.py -k unreferenced_triggers -q` 
(5 passed)
   
   Closes #77054


-- 
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