Class: ContainerRegistry::DeleteContainerRepositoryWorker

Inherits:
Object
  • Object
show all
Extended by:
Gitlab::Utils::Override
Includes:
ApplicationWorker, Gitlab::Utils::StrongMemoize, LimitedCapacity::Worker
Defined in:
app/workers/container_registry/delete_container_repository_worker.rb

Constant Summary collapse

MAX_CAPACITY =
2
CLEANUP_TAGS_SERVICE_PARAMS =
{
  'name_regex_delete' => '.*',
  'keep_latest' => false,
  'container_expiration_policy' => true # to avoid permissions checks
}.freeze

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from LimitedCapacity::Worker

#perform, #remove_failed_jobs, #report_prometheus_metrics

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#max_running_jobsObject



45
46
47
# File 'app/workers/container_registry/delete_container_repository_worker.rb', line 45

def max_running_jobs
  MAX_CAPACITY
end

#perform_workObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/workers/container_registry/delete_container_repository_worker.rb', line 24

def perform_work
  return unless next_container_repository

  result = delete_tags
  log_delete_tags_service_result(next_container_repository, result)

  if result[:status] == :error || next_container_repository.tags_count != 0
    return next_container_repository.set_delete_scheduled_status
  end

  next_container_repository.destroy!
rescue StandardError => exception
  next_container_repository&.set_delete_scheduled_status

  Gitlab::ErrorTracking.log_exception(exception, class: self.class.name)
end

#remaining_work_countObject



41
42
43
# File 'app/workers/container_registry/delete_container_repository_worker.rb', line 41

def remaining_work_count
  ::ContainerRepository.delete_scheduled.limit(max_running_jobs + 1).count
end