-
Notifications
You must be signed in to change notification settings - Fork 288
Fix the scheduler delay for new jobs, when the trigger is based on cr… #1944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughInitial-delay logic in the scheduler was tightened: cron-based schedules (CronScheduleRepeat) no longer receive the initial schedule delay. For non-cron triggers, NEW jobs get the initial delay — DynamicDelayRepeat returns its first delayPeriod; other non-cron types use INITIAL_SCHEDULE_DELAY_SEC. Subsequent delay branches unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Scheduler
participant Job
participant ScheduleParams
Note over Scheduler,ScheduleParams: New or subsequent run decision
Scheduler->>Job: inspect status
Scheduler->>ScheduleParams: inspect type
alt scheduling_params is CronScheduleRepeat
Scheduler->>Scheduler: compute next_delay via cron logic
else scheduling_params is DynamicDelayRepeat and Job.status == NEW
Scheduler->>Scheduler: return first delayPeriod
else scheduling_params not Cron and Job.status == NEW
Scheduler->>Scheduler: return INITIAL_SCHEDULE_DELAY_SEC
else
Scheduler->>Scheduler: compute subsequent delay (dynamic/fixed) and apply max-time adjustment
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)src/robusta/core/schedule/scheduler.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/robusta/core/schedule/scheduler.py (1)
134-154: The initialization issue is confirmed:last_exec_time_secstarts at 0 for NEW jobs.For NEW jobs with Cron scheduling, the code falls through to the calculation logic where
last_exec_time_sec = 0causes the formula0 + next_delay - round(time.time())to produce a large negative number. Themax()call then returnsINITIAL_SCHEDULE_DELAY_SEC, which masks the semantic error. NEW Cron jobs should return early withINITIAL_SCHEDULE_DELAY_SEC(like non-Cron NEW jobs do) rather than relying on this side-effect.The fix is to extend the early return check to include CronScheduleRepeat:
if job.state.job_status == JobStatus.NEW: if isinstance(job.scheduling_params, DynamicDelayRepeat): return job.scheduling_params.delay_periods[0] else: return INITIAL_SCHEDULE_DELAY_SEC
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/robusta/core/schedule/scheduler.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/robusta/core/schedule/scheduler.py (1)
src/robusta/core/schedule/model.py (3)
CronScheduleRepeat(25-26)JobStatus(7-10)DynamicDelayRepeat(21-22)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: run_tests
- GitHub Check: run_tests
- GitHub Check: Deploy docs
…on expression