fix(calendar): localize cron start_time to timetable timezone before computing planned runs - #71248
fix(calendar): localize cron start_time to timetable timezone before computing planned runs#71248waterWang wants to merge 1 commit into
Conversation
…computing planned runs
|
Closing this as part of a cleanup of a large batch of PRs opened in quick succession from this account. 18 PRs have been opened here in the past two weeks and none have merged. Several show signs of being generated and submitted without review: #71432 and #71433 are the same change across the same five files, opened two minutes apart, and several titles carry a leaked agent identifier that other contributors already flagged as garbled text on #70629 and #71322. Airflow is maintained by volunteers. Every PR costs reviewer time and CI capacity, so a high volume of unvetted submissions has a real cost to the project. You are welcome to keep contributing. Please open one change at a time, run it locally against the tests, and read the contributors' guide before submitting. If you think a specific change here is correct, comment with the reasoning and a maintainer can reopen it. |
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 cronschedule like
"0 8 * * *", the planned runs appear at 17:00 instead of08:00 — exactly a UTC-vs-local offset.
The root cause is in
CalendarService._calculate_cron_planned_runs():croniterreceiveslast_data_interval.end(a UTC-aware datetime) asstart_timeand reads its timezone — UTC — so the cron expression ismatched 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
Add imports for
convert_to_utc,make_aware,make_naivefromairflow._shared.timezones.timezone(same utilities used byCronMixin._get_next).In
_calculate_cron_planned_runs:_timezonefrom theCronMixincast.start_timeto that timezone viamake_naive()beforeconstructing
croniter.convert_to_utc(make_aware(...)).This matches the exact pattern used by
CronMixin._get_next()inairflow/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
airflow dags clearclearing the wrong day for non-UTC partitioned timetables #67717 (same pattern, fixed inairflow dags clear)next_dagrun_info_v2path for non-cron timetables)