From a1a9b9ba5c2f9a0e9b8e7ec4c690e808614fb378 Mon Sep 17 00:00:00 2001
From: feistel <6742251-feistel@users.noreply.gitlab.com>
Date: Mon, 23 May 2022 20:21:39 +0200
Subject: [PATCH] Remove ExpirePipelineCacheWorker and ExpireJobCacheWorker

---
 app/workers/all_queues.yml                    | 18 ---------
 app/workers/expire_job_cache_worker.rb        | 22 -----------
 app/workers/expire_pipeline_cache_worker.rb   | 27 -------------
 config/sidekiq_queues.yml                     |  2 -
 spec/commands/sidekiq_cluster/cli_spec.rb     | 10 ++---
 spec/workers/every_sidekiq_worker_spec.rb     |  2 -
 spec/workers/expire_job_cache_worker_spec.rb  | 31 ---------------
 .../expire_pipeline_cache_worker_spec.rb      | 38 -------------------
 8 files changed, 5 insertions(+), 145 deletions(-)
 delete mode 100644 app/workers/expire_job_cache_worker.rb
 delete mode 100644 app/workers/expire_pipeline_cache_worker.rb
 delete mode 100644 spec/workers/expire_job_cache_worker_spec.rb
 delete mode 100644 spec/workers/expire_pipeline_cache_worker_spec.rb

diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 8a525e455fd03..e3d897f9d6256 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -1614,24 +1614,6 @@
   :weight: 1
   :idempotent: true
   :tags: []
-- :name: pipeline_cache:expire_job_cache
-  :worker_name: ExpireJobCacheWorker
-  :feature_category: :continuous_integration
-  :has_external_dependencies:
-  :urgency: :high
-  :resource_boundary: :unknown
-  :weight: 3
-  :idempotent: true
-  :tags: []
-- :name: pipeline_cache:expire_pipeline_cache
-  :worker_name: ExpirePipelineCacheWorker
-  :feature_category: :continuous_integration
-  :has_external_dependencies:
-  :urgency: :high
-  :resource_boundary: :cpu
-  :weight: 3
-  :idempotent:
-  :tags: []
 - :name: pipeline_creation:ci_external_pull_requests_create_pipeline
   :worker_name: Ci::ExternalPullRequests::CreatePipelineWorker
   :feature_category: :continuous_integration
diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb
deleted file mode 100644
index eaa8810a78eef..0000000000000
--- a/app/workers/expire_job_cache_worker.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-class ExpireJobCacheWorker # rubocop:disable Scalability/IdempotentWorker
-  include ApplicationWorker
-
-  data_consistency :delayed
-
-  sidekiq_options retry: 3
-  include PipelineQueue
-
-  queue_namespace :pipeline_cache
-  urgency :high
-  idempotent!
-
-  def perform(job_id)
-    job = CommitStatus.find_by_id(job_id)
-    return unless job
-
-    job.expire_etag_cache!
-    ExpirePipelineCacheWorker.perform_async(job.pipeline_id)
-  end
-end
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
deleted file mode 100644
index 9a0c617da57c9..0000000000000
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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
-
-  # 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!
-
-  def perform(pipeline_id)
-    pipeline = Ci::Pipeline.find_by_id(pipeline_id)
-    return unless pipeline
-
-    Ci::ExpirePipelineCacheService.new.execute(pipeline)
-  end
-end
-# rubocop:enable Scalability/IdempotentWorker
diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml
index fc75752061fb3..2f7fa4137514e 100644
--- a/config/sidekiq_queues.yml
+++ b/config/sidekiq_queues.yml
@@ -329,8 +329,6 @@
   - 1
 - - pipeline_background
   - 1
-- - pipeline_cache
-  - 3
 - - pipeline_creation
   - 4
 - - pipeline_default
diff --git a/spec/commands/sidekiq_cluster/cli_spec.rb b/spec/commands/sidekiq_cluster/cli_spec.rb
index 223d0c3b0ecd2..3bc3b93c2503b 100644
--- a/spec/commands/sidekiq_cluster/cli_spec.rb
+++ b/spec/commands/sidekiq_cluster/cli_spec.rb
@@ -195,22 +195,22 @@
             },
             'high urgency CI queues' => {
               query: 'feature_category=continuous_integration&urgency=high',
-              included_queues: %w(pipeline_cache:expire_job_cache pipeline_cache:expire_pipeline_cache),
+              included_queues: %w(pipeline_default:ci_drop_pipeline),
               excluded_queues: %w(merge)
             },
             'CPU-bound high urgency CI queues' => {
               query: 'feature_category=continuous_integration&urgency=high&resource_boundary=cpu',
-              included_queues: %w(pipeline_cache:expire_pipeline_cache),
-              excluded_queues: %w(pipeline_cache:expire_job_cache merge)
+              included_queues: %w(pipeline_default:ci_create_downstream_pipeline),
+              excluded_queues: %w(pipeline_default:ci_drop_pipeline merge)
             },
             'CPU-bound high urgency non-CI queues' => {
               query: 'feature_category!=continuous_integration&urgency=high&resource_boundary=cpu',
               included_queues: %w(new_issue),
-              excluded_queues: %w(pipeline_cache:expire_pipeline_cache)
+              excluded_queues: %w(pipeline_default:ci_create_downstream_pipeline)
             },
             'CI and SCM queues' => {
               query: 'feature_category=continuous_integration|feature_category=source_code_management',
-              included_queues: %w(pipeline_cache:expire_job_cache merge),
+              included_queues: %w(pipeline_default:ci_drop_pipeline merge),
               excluded_queues: %w(mailers)
             }
           }
diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb
index 0c83a692ca807..055db578df8da 100644
--- a/spec/workers/every_sidekiq_worker_spec.rb
+++ b/spec/workers/every_sidekiq_worker_spec.rb
@@ -227,8 +227,6 @@
         'Epics::UpdateEpicsDatesWorker' => 3,
         'ErrorTrackingIssueLinkWorker' => 3,
         'Experiments::RecordConversionEventWorker' => 3,
-        'ExpireJobCacheWorker' => 3,
-        'ExpirePipelineCacheWorker' => 3,
         'ExportCsvWorker' => 3,
         'ExternalServiceReactiveCachingWorker' => 3,
         'FileHookWorker' => false,
diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb
deleted file mode 100644
index e9af39ed2df8a..0000000000000
--- a/spec/workers/expire_job_cache_worker_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ExpireJobCacheWorker do
-  let_it_be(:pipeline) { create(:ci_empty_pipeline) }
-
-  let(:project) { pipeline.project }
-
-  describe '#perform' do
-    context 'with a job in the pipeline' do
-      let_it_be(:job) { create(:ci_build, pipeline: pipeline) }
-
-      let(:job_args) { job.id }
-
-      it_behaves_like 'an idempotent worker'
-
-      it_behaves_like 'worker with data consistency',
-        described_class,
-        data_consistency: :delayed
-    end
-
-    context 'when there is no job in the pipeline' do
-      it 'does not change the etag store' do
-        expect(Gitlab::EtagCaching::Store).not_to receive(:new)
-
-        perform_multiple(non_existing_record_id)
-      end
-    end
-  end
-end
diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb
deleted file mode 100644
index f4c4df2e7521c..0000000000000
--- a/spec/workers/expire_pipeline_cache_worker_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ExpirePipelineCacheWorker do
-  let_it_be(:user) { create(:user) }
-  let_it_be(:project) { create(:project) }
-  let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
-
-  subject { described_class.new }
-
-  describe '#perform' do
-    it 'executes the service' do
-      expect_next_instance_of(Ci::ExpirePipelineCacheService) do |instance|
-        expect(instance).to receive(:execute).with(pipeline).and_call_original
-      end
-
-      subject.perform(pipeline.id)
-    end
-
-    it "doesn't do anything if the pipeline not exist" do
-      expect_any_instance_of(Ci::ExpirePipelineCacheService).not_to receive(:execute)
-      expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
-
-      subject.perform(617748)
-    end
-
-    skip "with https://gitlab.com/gitlab-org/gitlab/-/issues/325291 resolved" do
-      it_behaves_like 'an idempotent worker' do
-        let(:job_args) { [pipeline.id] }
-      end
-    end
-
-    it_behaves_like 'worker with data consistency',
-                  described_class,
-                  data_consistency: :delayed
-  end
-end
-- 
GitLab