2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWorker
|
2020-03-13 15:44:24 +05:30
|
|
|
include ApplicationWorker
|
|
|
|
include CronjobQueue
|
|
|
|
|
|
|
|
feature_category :container_registry
|
|
|
|
|
|
|
|
def perform
|
|
|
|
ContainerExpirationPolicy.runnable_schedules.preloaded.find_each do |container_expiration_policy|
|
|
|
|
with_context(project: container_expiration_policy.project,
|
|
|
|
user: container_expiration_policy.project.owner) do |project:, user:|
|
|
|
|
ContainerExpirationPolicyService.new(project, user)
|
|
|
|
.execute(container_expiration_policy)
|
2020-06-23 00:09:42 +05:30
|
|
|
rescue ContainerExpirationPolicyService::InvalidPolicyError => e
|
|
|
|
Gitlab::ErrorTracking.log_exception(e, container_expiration_policy_id: container_expiration_policy.id)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|