waterWang opened a new pull request, #71248:
URL: https://github.com/apache/airflow/pull/71248
Closes #71234
## Problem
Calendar view's planned/future runs for cron-based timetables are computed
in UTC wall-clock instead of the DAG's configured timezone. When a DAG
uses a non-UTC `default_timezone` (e.g. `Asia/Seoul`, UTC+9) with a cron
schedule like `"0 8 * * *"`, the planned runs appear at 17:00 instead of
08:00 — exactly a UTC-vs-local offset.
The root cause is in `CalendarService._calculate_cron_planned_runs()`:
`croniter` receives `last_data_interval.end` (a UTC-aware datetime) as
`start_time` and reads its timezone — UTC — so the cron expression is
matched against UTC wall-clock. The real scheduler (`CronMixin._get_next`)
correctly localizes the start time to the timetable's own timezone before
calling croniter.
## Fix
1. Add imports for `convert_to_utc`, `make_aware`, `make_naive` from
`airflow._shared.timezones.timezone` (same utilities used by
`CronMixin._get_next`).
2. In `_calculate_cron_planned_runs`:
- Extract the timetable's `_timezone` from the `CronMixin` cast.
- Localize `start_time` to that timezone via `make_naive()` before
constructing `croniter`.
- Convert each result back to UTC via `convert_to_utc(make_aware(...))`.
This matches the exact pattern used by `CronMixin._get_next()` in
`airflow/timetables/_cron.py`.
## Testing
All 19 existing calendar tests continue to pass. The fix was verified
locally by the issue reporter with an additional regression test for a
non-UTC cron timetable (20/20 passing).
## Related
- #71234 (original issue report with full reproduction steps)
- #67477 (fixed frontend layer; this completes the fix at the backend)
- #67717 (same pattern, fixed in `airflow dags clear`)
- #63631 (added timezone-aware `next_dagrun_info_v2` path for non-cron
timetables)
--
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]