"Keep latest artifacts" keeps artifacts of failed pipelines
Summary
Until there is a successful pipeline, the "Keep latest artifacts" feature (#16267 (closed)) keeps the artifacts of all failing pipelines
Steps to reproduce
- Create a project and setup a CI/CD pipeline with some artifacts
- Add a job which fails, for example by setting the
script
toexit 1
- Run the pipeline a few times
Example Project
https://gitlab.com/julrich/gitlab-keep-latest-artifacts-failing-pipeline
Note: When browsing the artifacts via the UI in the example project, it is not possible to open the artifacts of the failed pipelines (it shows the 404 page). This is maybe related to #249132. However, if you download the artifacts archive, it actually contains the artifacts so they are really still there.
What is the current bug behavior?
GitLab keeps the artifacts of the successful jobs of all failing pipelines.
All those artifacts will expire as soon as there is one successful pipeline. However, if the artifacts are big and the job keeps failing for some time, then this can quickly fill up a GitLab instance.
What is the expected correct behavior?
GitLab should only keep artifacts of successful pipelines despite the expires_in
setting.
Artifacts from jobs of failed pipelines should expire according to the expires_in
setting.
In doubt, it would probably be okay to keep the artifacts of the lastest failed pipeline as well. But keeping the artifacts of all failing pipelines since the last successful pipeline is not reasonable.
Relevant logs and/or screenshots
GitLabKeepLatestArtifactFailingPipeline
Also interesting to note: After the expiry time, the artifact download button vanishes from the pipeline page. Even for successful pipelines.
Output of checks
This bug happens on GitLab.com
Solution
I think we can unlock each pipeline as it fails with something like:
before_transition any => :failed do |pipeline, transition|
pipeline.locked = :unlocked
transition.args.first.try do |reason|
pipeline.failure_reason = reason
end
end
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.