diff options
Diffstat (limited to 'app/workers/ci/runners')
-rw-r--r-- | app/workers/ci/runners/process_runner_version_update_worker.rb | 25 | ||||
-rw-r--r-- | app/workers/ci/runners/reconcile_existing_runner_versions_cron_worker.rb | 18 |
2 files changed, 41 insertions, 2 deletions
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 |