diff --git a/src/scheduler/kubernetes/scheduler.py b/src/scheduler/kubernetes/scheduler.py index 5d568632..66107b0b 100644 --- a/src/scheduler/kubernetes/scheduler.py +++ b/src/scheduler/kubernetes/scheduler.py @@ -993,6 +993,20 @@ def handle_cron_jobs(self): # 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']]) + result = cursor.fetchone() + if result: + last_trigger = result['last_trigger'] + 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 + cursor.execute(''' UPDATE cronjob SET last_trigger = now()