summaryrefslogtreecommitdiff
path: root/app/workers/concerns/dependency_proxy
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/concerns/dependency_proxy')
-rw-r--r--app/workers/concerns/dependency_proxy/cleanup_worker.rb63
-rw-r--r--app/workers/concerns/dependency_proxy/expireable.rb2
2 files changed, 1 insertions, 64 deletions
diff --git a/app/workers/concerns/dependency_proxy/cleanup_worker.rb b/app/workers/concerns/dependency_proxy/cleanup_worker.rb
deleted file mode 100644
index b668634f233..00000000000
--- a/app/workers/concerns/dependency_proxy/cleanup_worker.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: true
-
-module DependencyProxy
- module CleanupWorker
- extend ActiveSupport::Concern
- include Gitlab::Utils::StrongMemoize
-
- def perform_work
- return unless artifact
-
- log_metadata(artifact)
-
- artifact.destroy!
- rescue StandardError
- artifact&.error!
- end
-
- def max_running_jobs
- ::Gitlab::CurrentSettings.dependency_proxy_ttl_group_policy_worker_capacity
- end
-
- def remaining_work_count
- expired_artifacts.limit(max_running_jobs + 1).count
- end
-
- private
-
- def model
- raise NotImplementedError
- end
-
- def log_metadata
- raise NotImplementedError
- end
-
- def log_cleanup_item
- raise NotImplementedError
- end
-
- def artifact
- strong_memoize(:artifact) do
- model.transaction do
- to_delete = next_item
-
- if to_delete
- to_delete.processing!
- log_cleanup_item(to_delete)
- end
-
- to_delete
- end
- end
- end
-
- def expired_artifacts
- model.expired
- end
-
- def next_item
- expired_artifacts.lock_next_by(:updated_at).first
- end
- end
-end
diff --git a/app/workers/concerns/dependency_proxy/expireable.rb b/app/workers/concerns/dependency_proxy/expireable.rb
index 9650ac85c6c..7e37db36bef 100644
--- a/app/workers/concerns/dependency_proxy/expireable.rb
+++ b/app/workers/concerns/dependency_proxy/expireable.rb
@@ -10,7 +10,7 @@ module DependencyProxy
def expire_artifacts(collection)
collection.each_batch(of: UPDATE_BATCH_SIZE) do |batch|
- batch.update_all(status: :expired)
+ batch.update_all(status: :pending_destruction)
end
end
end