fix: use configured Location for all schedule evaluations #2312#2313
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAll schedule evaluation points in ChangesScheduler Location Consistency Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #2312
Problem
The scheduler had a timezone asymmetry: start schedules and one-off schedules used raw
now(system clock time) while stop/restart schedules convertednowto the configuredcfg.Location. WhenDAGU_TZis configured to a different timezone than the server's local time, start schedules, one-off schedules, and catchup computations fire at the wrong wall-clock time.Root Cause
The misleading comment in
tick_planner.goclaimed robfig/cron applies the schedule's timezone internally — but the 5-field standard parser has no timezone support (noCRON_TZ=).Additionally,
os.Setenv("TZ", cfg.TZ)partially masks the bug by makingtime.Local == cfg.Location, but any code path that creates times without going throughtime.Now()(persisted watermarks, replay times, concurrent access) carries the wrong location.Fix
Use
now.In(tp.cfg.Location)consistently for ALL schedule evaluations:Plan()start schedulesnow→evalTime(now.In(cfg.Location))Plan()one-off schedulesnow→evalTimeInit()one-off reconciliationtp.cfg.Clock()→tp.cfg.Clock().In(tp.cfg.Location)recomputeBuffer()catchuptp.cfg.Clock()→tp.cfg.Clock().In(tp.cfg.Location)evalTimeis now computed once at the top ofPlan()and used in all four schedule loops (start, stop, restart, one-off).Impact
cfg.Location == time.LocalSummary by cubic
Fix a timezone mismatch in the scheduler. All schedules now use the configured location, so triggers fire at the expected wall-clock time when
DAGU_TZdiffers from the server timezone. Fixes #2312.evalTime := now.In(tp.cfg.Location)for all checks inPlan()(cron start and one-off).tp.cfg.Clock()totp.cfg.LocationinInit()reconciliation andrecomputeBuffer()catchup.robfig/cron5-field parser for timezone handling; no change whencfg.Location == time.Local.Written for commit 7249a67. Summary will update on new commits.
Summary by CodeRabbit