Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/run_pipeline_schedule_worker.rb')
-rw-r--r--app/workers/run_pipeline_schedule_worker.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/workers/run_pipeline_schedule_worker.rb b/app/workers/run_pipeline_schedule_worker.rb
index f31f006eec1..db82cf3af91 100644
--- a/app/workers/run_pipeline_schedule_worker.rb
+++ b/app/workers/run_pipeline_schedule_worker.rb
@@ -13,12 +13,18 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
deduplicate :until_executed
idempotent!
- def perform(schedule_id, user_id)
+ def perform(schedule_id, user_id, options = {})
schedule = Ci::PipelineSchedule.find_by_id(schedule_id)
user = User.find_by_id(user_id)
return unless schedule && schedule.project && user
+ if Feature.enabled?(:ci_use_run_pipeline_schedule_worker)
+ return if schedule.next_run_at > Time.current
+
+ update_next_run_at_for(schedule)
+ end
+
run_pipeline_schedule(schedule, user)
end
@@ -37,6 +43,12 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker
private
+ def update_next_run_at_for(schedule)
+ # Ensure `next_run_at` is set properly before creating a pipeline.
+ # Otherwise, multiple pipelines could be created in a short interval.
+ schedule.schedule_next_run!
+ end
+
def error(schedule, error)
failed_creation_counter.increment
log_error(schedule, error)