Class: Ci::PipelineArtifacts::DestroyAllExpiredService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::ExclusiveLeaseHelpers, Gitlab::LoopHelpers, Gitlab::Utils::StrongMemoize
Defined in:
app/services/ci/pipeline_artifacts/destroy_all_expired_service.rb

Constant Summary collapse

BATCH_SIZE =
100
LOOP_LIMIT =
1000
LOOP_TIMEOUT =
5.minutes
LOCK_TIMEOUT =
10.minutes
EXCLUSIVE_LOCK_KEY =
'expired_pipeline_artifacts:destroy:lock'

Constants included from Gitlab::ExclusiveLeaseHelpers

Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError

Instance Method Summary collapse

Methods included from Gitlab::LoopHelpers

#loop_until

Methods included from Gitlab::ExclusiveLeaseHelpers

#in_lock

Constructor Details

#initializeDestroyAllExpiredService

Returns a new instance of DestroyAllExpiredService.



16
17
18
19
# File 'app/services/ci/pipeline_artifacts/destroy_all_expired_service.rb', line 16

def initialize
  @removed_artifacts_count = 0
  @start_at = Time.current
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
# File 'app/services/ci/pipeline_artifacts/destroy_all_expired_service.rb', line 21

def execute
  in_lock(EXCLUSIVE_LOCK_KEY, ttl: LOCK_TIMEOUT, retries: 1) do
    destroy_unlocked_pipeline_artifacts

    legacy_destroy_pipeline_artifacts
  end

  @removed_artifacts_count
end