Scheduled pipelines scheduled to run at the same time as pipeline_schedule_worker gets pushed to the next run
We found this bug from a flaky spec: https://gitlab.com/gitlab-org/gitlab-ce/issues/63399. Originally, implemented in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28407
Currently we do:
self.next_run_at = Gitlab::Ci::CronParser.new(Settings.cron_jobs['pipeline_schedule_worker']['cron'],
Time.zone.name)
.next_time_from(ideal_next_run_at)
When ideal_next_run_at
here is equal to the next run of pipeline_schedule_worker
this returns the next run after that. This is because #next_time_from
is not inclusive.
For example, with our default pipeline_schedule_worker
schedule of every 19th minute of every hour:
- We create a scheduled pipeline that runs every 19th minute
- Time now is 12:00 and we want to set
next_run_at
-
ideal_next_run_at
is 12:19 which is 19 minutes from now -
next_run_at
should be 12:19 but 13:19 is set becauseGitlab::Ci::CronParser.new(...).next_time_from(ideal_next_run_at)
only considers times after the ideal run time. - So this scheduled pipeline that's supposed to run every hour is only ran every other hour
cc @dosuken123
Edited by Shinya Maeda