9f93395389
When the owner of a pipelines schedule was either blocked or was removed from the project, the pipeline schedular would still schedule the pipeline. This would than fail however, given the user had no access to the project and it contents. However, a better way to handle it would be to not schedule it at all. Furthermore, from now on, such schedules will be deactivated so the schedule worker can ignore it on the next runs.
25 lines
752 B
Ruby
25 lines
752 B
Ruby
class PipelineScheduleWorker
|
|
include Sidekiq::Worker
|
|
include CronjobQueue
|
|
|
|
def perform
|
|
Ci::PipelineSchedule.active.where("next_run_at < ?", Time.now)
|
|
.preload(:owner, :project).find_each do |schedule|
|
|
begin
|
|
unless schedule.runnable_by_owner?
|
|
schedule.deactivate!
|
|
next
|
|
end
|
|
|
|
Ci::CreatePipelineService.new(schedule.project,
|
|
schedule.owner,
|
|
ref: schedule.ref)
|
|
.execute(save_on_errors: false, schedule: schedule)
|
|
rescue => e
|
|
Rails.logger.error "#{schedule.id}: Failed to create a scheduled pipeline: #{e.message}"
|
|
ensure
|
|
schedule.schedule_next_run!
|
|
end
|
|
end
|
|
end
|
|
end
|