Skip to content

Add API endpoint and UI for deadline callback log visibility#66610

Open
seanghaeli wants to merge 18 commits into
apache:mainfrom
aws-mwaa:ghaeli/callback-log-ui-visibility
Open

Add API endpoint and UI for deadline callback log visibility#66610
seanghaeli wants to merge 18 commits into
apache:mainfrom
aws-mwaa:ghaeli/callback-log-ui-visibility

Conversation

@seanghaeli

@seanghaeli seanghaeli commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Make deadline callback logs visible in the Airflow UI. When a deadline is missed and a callback fires, users can now view the callback's execution logs directly from the web interface.

Changes

Backend:

  • New CallbackLogReader utility (airflow-core/src/airflow/utils/log/callback_log_reader.py) — reads callback logs from remote or local storage using the same RemoteLogIO infrastructure as task logs
  • New API endpoint GET /ui/dags/{dag_id}/dagRuns/{dag_run_id}/callbacks/{callback_id}/logs on the deadlines UI router
  • Updated DeadlineResponse datamodel — added callback_id and callback_state fields

Frontend:

  • CallbackLogViewer.tsx component — fetches and displays callback execution logs in a modal dialog
  • Simplified deadline status display: inline "Missed" badge + "Callback Logs" button + expected/actual times (no success badge, no "Finished late" text, no alert name)

Motivation

Kaxil requested this: "Some way to know if a deadline didn't fire and it failed: something on UI would be great, like Task log. If deadlines are visible, it would be even better experience than previous SLAs."

Dependencies


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.6)

Generated-by: Claude Code (Opus 4.6) following the guidelines

End-to-End Verification

Verified in breeze with full Airflow stack (scheduler + dag-processor + triggerer + API server + LocalExecutor). A test DAG with a SyncCallback deadline was parsed, unpaused, scheduled, and the deadline missed naturally. The callback executed through supervise_callback() and produced real structured logs.

Dag Run Page — Deadline Status with Callback

Deadline Status in Dag Run

Callback Logs Modal

Callback Logs Modal

Verified:

  • 6/6 API unit tests pass (test_callback_logs.py)
  • 12/12 log reader unit tests pass (test_callback_log_reader.py)
  • Path traversal protection via regex validation + os.path.commonpath containment check
  • Stress tested with 10K-100K line logs: 10K lines renders in 0.23s, acceptable for realistic callback output

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:logging labels May 8, 2026
Comment thread airflow-core/src/airflow/utils/log/callback_log_reader.py Fixed
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch from 2b1e618 to 9102967 Compare May 13, 2026 22:37
Comment thread airflow-core/src/airflow/utils/log/callback_log_reader.py Fixed
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch 9 times, most recently from e303ead to f6103b3 Compare May 23, 2026 17:36
Comment thread airflow-core/src/airflow/utils/log/callback_log_reader.py Fixed
@vincbeck

Copy link
Copy Markdown
Contributor

I like the interface but I would like to have @bbovenzi opinion on this one

@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch 2 times, most recently from e8a1b93 to 528ce64 Compare June 5, 2026 19:24
@seanghaeli seanghaeli requested a review from o-nikolas as a code owner June 5, 2026 21:21
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch 2 times, most recently from 400961e to b9a6f9c Compare June 8, 2026 18:13
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch from 368fb19 to 8ce33e6 Compare June 8, 2026 20:44
Async (TriggererCallback) deadline callbacks now have their logs captured
to a dedicated file path that the UI log endpoint can read, matching the
pattern already established for sync (ExecutorCallback) logs.

Changes:
- TriggerLoggingFactory.ti is now optional (None for callback triggers)
- _create_workload sets up logger_cache for callback triggers without a
  task instance, writing to triggerer_callbacks/{dag_id}/{run_id}/{cb_id}
- callback_log_reader checks both executor_callbacks/ and
  triggerer_callbacks/ paths when reading logs
- upload_to_remote gracefully handles ti=None by uploading directly
  via the remote log handler
@ashb

ashb commented Jun 10, 2026

Copy link
Copy Markdown
Member

Why is the callback logs a modal, rather than a tab? (I'm not saying it's wrong, I would just like to know your thinking and what made you chose this over another option)

Additionally we should likely use the existing log component so that it gets the same filtering, formatting, and grouping, not just displayed as plain text.

@seanghaeli

Copy link
Copy Markdown
Contributor Author

@ashb I thought about making the logs appear in a new tab next to Details where the rest of the logs are, but this page only appears when a deadline is missed, so grouping it up with the “Deadline Missed” section makes more spatial sense in my opinion.

Address review feedback from Ash — use the existing log component
(TaskLogContent) instead of a custom renderer so callback logs get
the same filtering, formatting, grouping, and virtualization as task
instance logs.
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch from 6ab1317 to 1c8fc49 Compare June 10, 2026 14:54
@seanghaeli

Copy link
Copy Markdown
Contributor Author

@ashb updated to use TaskLogContent

Sean Ghaeli added 4 commits June 10, 2026 17:15
The (datum as StructuredLogMessage) cast was redundant — datum is already
narrowed by the typeof check. CI's lint autofix stripped the cast, which
left the StructuredLogMessage import unused and triggered TS6196. Remove
both the cast and the now-unused import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:logging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants