diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-16 15:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-16 15:09:03 +0300 |
commit | 8215fc964a189ae5c876a10f2e7d61933a725e24 (patch) | |
tree | acdd0abd951ca0f392c7617821ab347d77c1a623 /app/workers | |
parent | a57cec4bb89b61d210d4e413571b1d85d76179f6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/all_queues.yml | 8 | ||||
-rw-r--r-- | app/workers/packages/composer/cache_cleanup_worker.rb | 30 |
2 files changed, 38 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 6d4e6de30d9..59ab0a4d05b 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -267,6 +267,14 @@ :weight: 1 :idempotent: :tags: [] +- :name: cronjob:packages_composer_cache_cleanup + :feature_category: :package_registry + :has_external_dependencies: + :urgency: :low + :resource_boundary: :unknown + :weight: 1 + :idempotent: true + :tags: [] - :name: cronjob:pages_domain_removal_cron :feature_category: :pages :has_external_dependencies: diff --git a/app/workers/packages/composer/cache_cleanup_worker.rb b/app/workers/packages/composer/cache_cleanup_worker.rb new file mode 100644 index 00000000000..638e50e18c4 --- /dev/null +++ b/app/workers/packages/composer/cache_cleanup_worker.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Packages + module Composer + class CacheCleanupWorker + include ApplicationWorker + include CronjobQueue # rubocop:disable Scalability/CronWorkerContext + + feature_category :package_registry + + idempotent! + + def perform + ::Packages::Composer::CacheFile.without_namespace.find_in_batches do |cache_files| + cache_files.each(&:destroy) + rescue ActiveRecord::RecordNotFound + # ignore. likely due to object already being deleted. + end + + ::Packages::Composer::CacheFile.expired.find_in_batches do |cache_files| + cache_files.each(&:destroy) + rescue ActiveRecord::RecordNotFound + # ignore. likely due to object already being deleted. + end + rescue => e + Gitlab::ErrorTracking.log_exception(e) + end + end + end +end |