Skip to content

Commit

Permalink
fix scheduler bug (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
arikalon1 authored Apr 16, 2023
1 parent b78adbb commit 7b320c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/robusta/core/schedule/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def __remove_scheduler_job(self, job_id):

def __is_job_done(self, job: ScheduledJob) -> bool:
if isinstance(job.scheduling_params, DynamicDelayRepeat):
return job.state.exec_count == len(job.scheduling_params.delay_periods)
return job.state.exec_count >= len(job.scheduling_params.delay_periods)
else: # default, FIXED_DELAY_REPEAT
return job.state.exec_count == job.scheduling_params.repeat
return job.state.exec_count >= job.scheduling_params.repeat

def __calc_job_delay_for_next_run(self, job: ScheduledJob):
if job.state.job_status == JobStatus.NEW:
Expand All @@ -136,7 +136,8 @@ def __calc_job_delay_for_next_run(self, job: ScheduledJob):
return INITIAL_SCHEDULE_DELAY_SEC

if isinstance(job.scheduling_params, DynamicDelayRepeat):
next_delay = job.scheduling_params.delay_periods[job.state.exec_count]
next_delay_idx = min(job.state.exec_count, len(job.scheduling_params.delay_periods) - 1)
next_delay = job.scheduling_params.delay_periods[next_delay_idx]
else: # FIXED_DELAY_REPEAT type
next_delay = job.scheduling_params.seconds_delay

Expand Down
4 changes: 2 additions & 2 deletions src/robusta/integrations/scheduled/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def get_params(self) -> Union[FixedDelayRepeat, DynamicDelayRepeat]:


class FixedDelayRepeatTrigger(ScheduledTrigger):
fixed_delay_repeat: Optional[FixedDelayRepeat]
fixed_delay_repeat: FixedDelayRepeat

def get_params(self) -> Union[FixedDelayRepeat, DynamicDelayRepeat]:
return self.fixed_delay_repeat


class DynamicDelayRepeatTrigger(ScheduledTrigger):
dynamic_delay_repeat: Optional[DynamicDelayRepeat]
dynamic_delay_repeat: DynamicDelayRepeat

def get_params(self) -> Union[FixedDelayRepeat, DynamicDelayRepeat]:
return self.dynamic_delay_repeat
Expand Down

0 comments on commit 7b320c4

Please sign in to comment.