diff options
Diffstat (limited to 'app/workers/ci')
5 files changed, 93 insertions, 4 deletions
diff --git a/app/workers/ci/build_finished_worker.rb b/app/workers/ci/build_finished_worker.rb index 25c7637a79f..36a50735fed 100644 --- a/app/workers/ci/build_finished_worker.rb +++ b/app/workers/ci/build_finished_worker.rb @@ -36,8 +36,7 @@ module Ci build.update_coverage Ci::BuildReportResultService.new.execute(build) - # We execute these async as these are independent operations. - BuildHooksWorker.perform_async(build) + build.feature_flagged_execute_hooks ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat? build.track_deployment_usage build.track_verify_usage diff --git a/app/workers/ci/cancel_pipeline_worker.rb b/app/workers/ci/cancel_pipeline_worker.rb new file mode 100644 index 00000000000..147839a0625 --- /dev/null +++ b/app/workers/ci/cancel_pipeline_worker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Ci + class CancelPipelineWorker + include ApplicationWorker + + # lots of updates to ci_builds + data_consistency :always + feature_category :continuous_integration + idempotent! + deduplicate :until_executed + urgency :high + + def perform(pipeline_id, auto_canceled_by_pipeline_id) + ::Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline| + pipeline.cancel_running( + # cascade_to_children is false because we iterate through children + # we also cancel bridges prior to prevent more children + cascade_to_children: false, + auto_canceled_by_pipeline_id: auto_canceled_by_pipeline_id + ) + end + end + end +end diff --git a/app/workers/ci/runners/process_runner_version_update_worker.rb b/app/workers/ci/runners/process_runner_version_update_worker.rb new file mode 100644 index 00000000000..f1ad0c8563e --- /dev/null +++ b/app/workers/ci/runners/process_runner_version_update_worker.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Ci + module Runners + class ProcessRunnerVersionUpdateWorker + include ApplicationWorker + + data_consistency :always + + feature_category :runner_fleet + urgency :low + + idempotent! + deduplicate :until_executing + + def perform(version) + result = ::Ci::Runners::ProcessRunnerVersionUpdateService.new(version).execute + + result.to_h.slice(:status, :message, :upgrade_status).each do |key, value| + log_extra_metadata_on_done(key, value) + end + end + end + end +end diff --git a/app/workers/ci/runners/reconcile_existing_runner_versions_cron_worker.rb b/app/workers/ci/runners/reconcile_existing_runner_versions_cron_worker.rb index 035b2563e56..69ab477c80a 100644 --- a/app/workers/ci/runners/reconcile_existing_runner_versions_cron_worker.rb +++ b/app/workers/ci/runners/reconcile_existing_runner_versions_cron_worker.rb @@ -12,11 +12,25 @@ module Ci feature_category :runner_fleet urgency :low + deduplicate :until_executed idempotent! - def perform + def perform(cronjob_scheduled = true) + if cronjob_scheduled + # Introduce some randomness across the day so that instances don't all hit the GitLab Releases API + # around the same time of day + period = rand(0..12.hours.in_seconds) + self.class.perform_in(period, false) + + Sidekiq.logger.info( + class: self.class.name, + message: "rescheduled job for #{period.seconds.from_now}") + + return + end + result = ::Ci::Runners::ReconcileExistingRunnerVersionsService.new.execute - result.each { |key, value| log_extra_metadata_on_done(key, value) } + result.payload.each { |key, value| log_extra_metadata_on_done(key, value) } end end end diff --git a/app/workers/ci/track_failed_build_worker.rb b/app/workers/ci/track_failed_build_worker.rb new file mode 100644 index 00000000000..2ad948876ac --- /dev/null +++ b/app/workers/ci/track_failed_build_worker.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# Worker for tracking exit codes of failed CI jobs +module Ci + class TrackFailedBuildWorker # rubocop:disable Scalability/IdempotentWorker + include ApplicationWorker + include PipelineBackgroundQueue + + feature_category :static_application_security_testing + + urgency :low + data_consistency :sticky + worker_resource_boundary :cpu + idempotent! + worker_has_external_dependencies! + + def perform(build_id, exit_code, failure_reason) + ::Ci::Build.find_by_id(build_id).try do |build| + ::Ci::TrackFailedBuildService.new( + build: build, + exit_code: exit_code, + failure_reason: failure_reason).execute + end + end + end +end |