You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "waterWang (via GitHub)" <gi...@apache.org> on 2026/08/06 17:00:48 UTC

[PR] fix(calendar): localize cron start_time to timetable timezone before computing planned runs [airflow]

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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(calendar): localize cron start_time to timetable timezone before computing planned runs [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed pull request #71248: fix(calendar): localize cron start_time to timetable timezone before computing planned runs
URL: https://github.com/apache/airflow/pull/71248


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(calendar): localize cron start_time to timetable timezone before computing planned runs [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #71248:
URL: https://github.com/apache/airflow/pull/71248#issuecomment-5259034394

   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](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) before submitting. If you think a specific change here is correct, comment with the reasoning and a maintainer can reopen it.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org