summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-20 09:50:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-20 09:50:23 +0000
commit5d4c627a70247d545ac695665e9ce4d07887e116 (patch)
treeba9ce2baf16cf7092dcca102862955785ec706d5
parentc6bad18a5a8a66eaa641f5bf0177e3d7015c3cfa (diff)
downloadgitlab-ce-5d4c627a70247d545ac695665e9ce4d07887e116.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-ee
-rw-r--r--app/workers/all_queues.yml9
-rw-r--r--app/workers/git_garbage_collect_worker.rb19
-rw-r--r--config/sidekiq_queues.yml2
-rw-r--r--spec/workers/git_garbage_collect_worker_spec.rb26
4 files changed, 56 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 07c1ce0d939..b216c2bff28 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -2116,6 +2116,15 @@
:idempotent: true
:tags:
- :exclude_from_kubernetes
+- :name: git_garbage_collect
+ :worker_name: GitGarbageCollectWorker
+ :feature_category: :gitaly
+ :has_external_dependencies:
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
- :name: github_import_advance_stage
:worker_name: Gitlab::GithubImport::AdvanceStageWorker
:feature_category: :importers
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb
new file mode 100644
index 00000000000..a2aab23db7b
--- /dev/null
+++ b/app/workers/git_garbage_collect_worker.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+# According to our docs, we can only remove workers on major releases
+# https://docs.gitlab.com/ee/development/sidekiq_style_guide.html#removing-workers.
+#
+# We need to still maintain this until 14.0 but with the current functionality.
+#
+# In https://gitlab.com/gitlab-org/gitlab/-/issues/299290 we track that removal.
+class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ sidekiq_options retry: false
+ feature_category :gitaly
+ loggable_arguments 1, 2, 3
+
+ def perform(project_id, task = :gc, lease_key = nil, lease_uuid = nil)
+ ::Projects::GitGarbageCollectWorker.new.perform(project_id, task, lease_key, lease_uuid)
+ end
+end
diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml
index 02fe21a9e6e..fed37b99715 100644
--- a/config/sidekiq_queues.yml
+++ b/config/sidekiq_queues.yml
@@ -152,6 +152,8 @@
- 1
- - geo
- 1
+- - git_garbage_collect
+ - 1
- - github_import_advance_stage
- 1
- - github_importer
diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb
new file mode 100644
index 00000000000..3df64c35166
--- /dev/null
+++ b/spec/workers/git_garbage_collect_worker_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'fileutils'
+
+require 'spec_helper'
+
+RSpec.describe GitGarbageCollectWorker do
+ let_it_be(:project) { create(:project, :repository) }
+
+ let(:lease_uuid) { SecureRandom.uuid }
+ let(:lease_key) { "project_housekeeping:#{project.id}" }
+ let(:task) { :full_repack }
+ let(:params) { [project.id, task, lease_key, lease_uuid] }
+
+ subject { described_class.new }
+
+ describe "#perform" do
+ it 'calls the Projects::GitGarbageGitGarbageCollectWorker with the same params' do
+ expect_next_instance_of(Projects::GitGarbageCollectWorker) do |instance|
+ expect(instance).to receive(:perform).with(*params)
+ end
+
+ subject.perform(*params)
+ end
+ end
+end