Module: Packages::CleanupArtifactWorker

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Utils::StrongMemoize, LimitedCapacity::Worker
Included in:
DependencyProxy::CleanupBlobWorker, DependencyProxy::CleanupManifestWorker, CleanupPackageFileWorker
Defined in:
app/workers/concerns/packages/cleanup_artifact_worker.rb

Instance Method Summary collapse

Methods included from LimitedCapacity::Worker

#max_running_jobs, #perform, #remove_failed_jobs, #report_prometheus_metrics

Instance Method Details

#perform_workObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/workers/concerns/packages/cleanup_artifact_worker.rb', line 9

def perform_work
  return unless artifact

  begin
    artifact.transaction do
      (artifact)

      artifact.destroy!
    end
  rescue StandardError => exception
    unless artifact&.destroyed?
      artifact&.update_column(:status, :error)
    end

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

  after_destroy
end

#remaining_work_countObject



32
33
34
# File 'app/workers/concerns/packages/cleanup_artifact_worker.rb', line 32

def remaining_work_count
  artifacts_pending_destruction.limit(max_running_jobs + 1).count
end