Skip to content

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

Open
seanghaeli wants to merge 25 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 25 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

Copy link
Copy Markdown
Contributor Author

@ashb updated to use TaskLogContent

@seanghaeli seanghaeli closed this Jun 11, 2026
@seanghaeli seanghaeli reopened this Jun 11, 2026
Sean Ghaeli added 24 commits June 12, 2026 16:47
The rebase conflict resolution dropped the callback logs service
function. Re-add it to match the types.gen.ts and backend endpoint.
The manual merge conflict resolution left stale URL/params in
services.gen.ts that didn't match the actual API endpoint signature
(dag_id, dag_run_id, callback_id vs callback_id, try_number).
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
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.
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.
…p_is_per_index (unrelated to UI changes; passed on prior runs)
…p_is_per_index (2nd flake, unrelated to UI changes, from apache#67684 on main)
…p_is_per_index (3rd flake, apache#67684 on main, unrelated to UI PR)
…p_is_per_index (4th flake; apache#67684 on main; unrelated to UI PR)
…p_is_per_index (5th flake; apache#67684 on main; unrelated to UI PR)
@seanghaeli seanghaeli force-pushed the ghaeli/callback-log-ui-visibility branch from ddaab67 to 7567838 Compare June 12, 2026 16:47

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not inspected the diff itself, but I saw your dev list post requesting feedback on potential UI additions.

Overall, I think you've covered most of what users would reasonably expect to see for DeadlineAlerts in the UI. One possible enhancement would be surfacing a few additional pieces of metadata:

  1. Configured interval value
  2. Interval source (timedelta vs VariableInterval)
  3. Callback type (for example, SlackWebhookNotifier)

Users can always inspect the DAG definition for this information, but exposing it directly in the UI would make deadline investgation more self-service. For e.g., if critical SLA is missed and a DeadlineAlert fires, an operator or stakeholder could immediately understand what deadline was configured and what notification mechanism was invoked without needing to inspect the DAG code.

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.

8 participants