diff --git a/src/scheduler/kubernetes/scheduler.py b/src/scheduler/kubernetes/scheduler.py index 5d568632..20cec847 100644 --- a/src/scheduler/kubernetes/scheduler.py +++ b/src/scheduler/kubernetes/scheduler.py @@ -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