Commit 6891abfe authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rs-artifact-lock-ff' into 'master'

Gate "keep latest artifacts for ref" behind feature flag

See merge request gitlab-org/gitlab!30765
parents 78b68298 3da767d8
......@@ -33,8 +33,7 @@ module Ci
file_type: params['artifact_type'],
file_format: params['artifact_format'],
file_sha256: artifacts_file.sha256,
expire_in: expire_in,
locked: true)
expire_in: expire_in)
artifact_metadata = if metadata_file
Ci::JobArtifact.new(
......@@ -44,10 +43,14 @@ module Ci
file_type: :metadata,
file_format: :gzip,
file_sha256: metadata_file.sha256,
expire_in: expire_in,
locked: true)
expire_in: expire_in)
end
if Feature.enabled?(:keep_latest_artifact_for_ref, job.project)
artifact.locked = true
artifact_metadata&.locked = true
end
[artifact, artifact_metadata]
end
......@@ -85,6 +88,8 @@ module Ci
end
def unlock_previous_artifacts!(artifact)
return unless Feature.enabled?(:keep_latest_artifact_for_ref, artifact.job.project)
Ci::JobArtifact.for_ref(artifact.job.ref, artifact.project_id).locked.update_all(locked: false)
end
......
......@@ -28,7 +28,13 @@ module Ci
private
def destroy_batch
artifacts = Ci::JobArtifact.expired(BATCH_SIZE).unlocked.to_a
artifact_batch = if Feature.enabled?(:keep_latest_artifact_for_ref)
Ci::JobArtifact.expired(BATCH_SIZE).unlocked
else
Ci::JobArtifact.expired(BATCH_SIZE)
end
artifacts = artifact_batch.to_a
return false if artifacts.empty?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment