Job artifacts in blocked pipelines (status: manual) are always marked as latest
Spin off from #266958 (comment 1226877383)
pipeline status is typically
blocked
due to a manual deployment job not having been run, and all jobs show as having the latest artifacts. This leads to an unwanted accumulation of artifact storage.
"blocked" pipeline is either in
manual
orscheduled
state. Thesepipeline
states don't trigger an update on theci_ref
state.
This issue is to fix this bug and ensure that blocked pipelines that are not the latest are correctly unlocked.
Current behaviour
When a pipeline ends in "blocked" state, for example when using rules: when manual
, it does not unlock previous pipelines. The job artifacts are still showing as latest.
Example in this project: https://gitlab.com/alberts-gitlab/test-block-pipeline-unlock-artifacts/-/pipelines
- Latest blocked pipeline #738766496: Job artifact is correctly marked as latest
- Pipeline -1 (blocked) #738766186: Job artifact is still marked as latest, where it should not be.
- Pipeline -3 (success) #738765003: Job artifact is still marked as latest, where it should not be.
Expected behaviour
- Given a latest pipeline on the ref with a manual job, when this pipeline ends in "blocked" state, then all previous pipelines should have their job artifacts unlocked.
- Given a latest pipeline on the ref with a manual job that is in "blocked" state, when the manual job is executed successfully, then all previous pipelines should have their job artifacts unlocked.
Potential cause
This could be caused by mismatch between the ci_pipeline
state transition and ci_ref
state transition.
At the moment, previous pipelines are unlocked when ci_ref
transitions into success
or fixed
. So the question becomes, what causes this ci_ref
transition. This only occurs when both of the following happens:
-
pipeline
status is 'success' whenci_ref.update_status_by!
is called. -
pipeline
state transition callsci_ref.update_status_by!
. This only happens when pipeline transitions intosuccess
orfailed
, not any of the blocked states.