Class: ContainerExpirationPolicyWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/container_expiration_policy_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject


9
10
11
12
13
14
15
16
17
18
19
# File 'app/workers/container_expiration_policy_worker.rb', line 9

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)
    rescue ContainerExpirationPolicyService::InvalidPolicyError => e
      Gitlab::ErrorTracking.log_exception(e, container_expiration_policy_id: container_expiration_policy.id)
    end
  end
end