goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
23.62k stars 4.72k forks source link

Option to automatically delete artifacts made tagless by push #19157

Open tostt opened 1 year ago

tostt commented 1 year ago

The problem In the context of DevOps development, some projects create "work in progress" docker images multiple times a day with the same tag, for instance SNAPSHOT. When each new SHAPSHOT image is pushed on Harbor, this creates a new artifact, tagged with SNAPSHOT, while the previously SNAPHOT-tagged artifact is untagged any may becomes tagless (unless it had multiple tags before the push). This means that the repository can quickly fill up with tagless artifacts, which is detrimental to the user experience (theses artifacts are usually useless and will never be pulled again).

Describe the solution you'd like Offer a new artifact policy which will, after each push, automatically delete the possibly tagless artifact. This could take the form of a third button/tab in the "Policy" tab of the project, alongside the existing "Tag retention" and "Tag immutability". It could be called 'Tagless artifacts". In this tab, users could chose to enable the option "Automatically delete artifacts made tagless by push". This would delete at most one (tagless) artifact with the same name. It would not delete the artifact if it has at least one tag.

Ouside the scope of the proposal Garbage collection is outside the scope of this proposal.

chlins commented 1 year ago

While currently no such direct option is available, but you can achieve your desired outcome by combining scheduled tag retention and garbage collection.

tostt commented 1 year ago

Thank you for your answer. Indeed, that's what I am doing currently, with a GC planned every hour.