summaryrefslogtreecommitdiff
path: root/app/workers/expire_pipeline_cache_worker.rb
blob: 9702fac39ba49f90a9b3bf8f91ae5a0a223e0200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

# rubocop: disable Scalability/IdempotentWorker
class ExpirePipelineCacheWorker
  include ApplicationWorker

  sidekiq_options retry: 3
  include PipelineQueue

  queue_namespace :pipeline_cache
  urgency :high
  worker_resource_boundary :cpu
  data_consistency :delayed, feature_flag: :load_balancing_for_expire_pipeline_cache_worker

  # This worker _should_ be idempotent, but due to us moving this to data_consistency :delayed
  # and an ongoing incompatibility between the two switches, we need to disable this.
  # Uncomment once https://gitlab.com/gitlab-org/gitlab/-/issues/325291 is resolved
  # idempotent!

  # rubocop: disable CodeReuse/ActiveRecord
  def perform(pipeline_id)
    pipeline = Ci::Pipeline.eager_load_project.find_by(id: pipeline_id)
    return unless pipeline

    Ci::ExpirePipelineCacheService.new.execute(pipeline)
  end
  # rubocop: enable CodeReuse/ActiveRecord
end
# rubocop:enable Scalability/IdempotentWorker