Skip to content

Commit

Permalink
fix cron
Browse files Browse the repository at this point in the history
  • Loading branch information
chengshifan committed May 23, 2024
1 parent 404b150 commit 70284e4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/scheduler/kubernetes/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,18 @@ def handle_cron_jobs(self):

next_trigger = i.get_next(datetime)

if next_trigger > datetime.now():
# still in future
continue

# Double-check the next_trigger by selecting the latest last_trigger for the cronjob
cursor.execute("""
SELECT last_trigger
FROM cronjob
WHERE id = %s """, [c['id']])
last_trigger = cursor.fetchone()
i = croniter('%s %s %s %s %s' % (c['minute'], c['hour'], c['day_month'], c['month'], c['day_week']), last_trigger)
next_trigger = i.get_next(datetime)
if next_trigger > datetime.now():
# still in future
continue
Expand Down

0 comments on commit 70284e4

Please sign in to comment.