2020-01-11 10:07:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWorker
|
2020-01-11 10:07:49 -05:00
|
|
|
include ApplicationWorker
|
2020-02-11 10:08:44 -05:00
|
|
|
include CronjobQueue
|
2020-01-11 10:07:49 -05:00
|
|
|
|
|
|
|
feature_category :container_registry
|
|
|
|
|
|
|
|
def perform
|
|
|
|
ContainerExpirationPolicy.runnable_schedules.preloaded.find_each do |container_expiration_policy|
|
2020-02-11 10:08:44 -05:00
|
|
|
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-16 02:08:27 -04:00
|
|
|
rescue ContainerExpirationPolicyService::InvalidPolicyError => e
|
|
|
|
Gitlab::ErrorTracking.log_exception(e, container_expiration_policy_id: container_expiration_policy.id)
|
2020-02-11 10:08:44 -05:00
|
|
|
end
|
2020-01-11 10:07:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|