debian-mirror-gitlab/app/workers/expire_job_cache_worker.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2021-11-11 11:23:49 +05:30
class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2021-06-08 01:23:25 +05:30
2021-11-11 11:23:49 +05:30
data_consistency :delayed
2021-10-27 15:23:28 +05:30
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2018-03-17 18:26:18 +05:30
include PipelineQueue
queue_namespace :pipeline_cache
2020-04-08 14:13:33 +05:30
urgency :high
2021-11-11 11:23:49 +05:30
# This worker should be idempotent, but we're switching to data_consistency
# :sticky and there is an ongoing incompatibility, so it needs to be disabled for
# now. The following line can be uncommented and this comment removed once
# https://gitlab.com/gitlab-org/gitlab/-/issues/325291 is resolved.
# idempotent!
2017-08-17 22:00:37 +05:30
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
def perform(job_id)
2021-11-11 11:23:49 +05:30
job = CommitStatus.preload(:pipeline, :project).find_by(id: job_id)
2017-08-17 22:00:37 +05:30
return unless job
pipeline = job.pipeline
project = job.project
2021-04-17 20:07:23 +05:30
Gitlab::EtagCaching::Store.new.touch(project_job_path(project, job))
ExpirePipelineCacheWorker.perform_async(pipeline.id)
2017-08-17 22:00:37 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
private
def project_job_path(project, job)
2017-09-10 17:25:29 +05:30
Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json)
2017-08-17 22:00:37 +05:30
end
end