Conversation
|
Nice work @dlaw4608! I think this a great contribution that we'll need to run at least once across multiple quay repositories as we have so many stale/obselete tags that is comsuming unnessary quota in our quay repositories. I'll continue on your work and address anything outstanding 👍 |
quay/quay_overflow.go
Outdated
| robotPass = os.Getenv("ROBOT_PASS") | ||
| robotUser = os.Getenv("ROBOT_USER") | ||
| accessToken = os.Getenv("ACCESS_TOKEN") | ||
| preserveSubstring = "latest" // Example Tag name that wont be deleted i.e relevant tags |
There was a problem hiding this comment.
So we want to delete all old tags that are not latest!? What about vX.Y.Z release tags? We may want to expand this to a list of patterns to preserve, I suppose.
There was a problem hiding this comment.
I think it's only latest as it was a PoC, but yes, I'm also thinking of a list of patterns to perserve, such as released tags and release branches 🤔
|
Thinking on this, we should probably prevent the image overflow from continuing first (#851) before we look to run something like this to clean up the old/obselete tags |
b6c621d to
c9eb415
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #843 +/- ##
==========================================
- Coverage 82.08% 82.04% -0.05%
==========================================
Files 76 76
Lines 6090 6092 +2
==========================================
- Hits 4999 4998 -1
- Misses 746 747 +1
- Partials 345 347 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
92eeb7c to
125b3f0
Compare
Signed-off-by: dlaw4608 <dlawton032@gmail.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
…y label Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
Signed-off-by: KevFan <chfan@redhat.com>
dcc8f79 to
26b34d8
Compare
Signed-off-by: KevFan <chfan@redhat.com>
|
Given there's no movement on this PR, I'm going to close and reopen again if this comes up again as something we still want to do |
Closes #769
This pull request introduces a proposed solution for managing the accumulation of image tags in the Quay.io repository.
Core Process:
It automates the cleanup process by filtering out older tags that are no longer relevant, while preserving tags deemed important (e.g., those containing a specific substring). The main components of this solution include fetching tags, filtering based on age and relevance, and deleting obsolete tags.
Key Components:
1. Tag Fetching (fetchTags):
Retrieves image tags from the Quay.io API using the appropriate authentication method.
Handles various HTTP response scenarios and errors.
2. Tag Filtering (filterTags):
Filters tags based on their last modified date and whether they contain a predefined substring.
Classifies tags into those to be deleted and those to be retained.
3. Tag Deletion (deleteTag):
Deletes specified tags from the repository using HTTP DELETE requests.
Handles different response scenarios to determine the success of the deletion operation.
package main
Testing:
To ensure the correctness of the implementation, mock tests have been added to simulate different HTTP responses and scenarios:
fetchTags Tests:
Error Making Request: Simulates a network error to verify error handling.
Non-200 Status Codes: Simulates API responses with error status codes (e.g., 400) to ensure proper error reporting.
JSON Parsing Errors: Tests the handling of malformed JSON responses.
Successful Response: Validates correct parsing of a successful response with sample tag data.
deleteTag Tests:
filterTags Tests:
Proposed future solution:
Instead of relying on a custom script that requires manual execution, leveraging the built-in expiration policy available in Quay.io presents a more clean and efficient solution. By using Quay.io's expiration policy, we can automatically manage and clean up old image tags without the need for additional maintenance.
1. Expiration Policy Setup:
Quay.io allows you to define expiration rules directly within the repository settings. These rules can automatically delete image tags after a specified period, such as 6 months, ensuring that outdated and unused images are purged from the repository.
2. Tagging Strategy:
Modify the image tagging process in your CI/CD pipeline to include a timestamp on non-critical tags. For example, tags could be formatted as v1.0.0-20250229 (for an image that expires on February 29, 2025).
Tags that should be preserved indefinitely, like latest, would not include a timestamp, thereby excluding them from the expiration policy.
3. Implementation in CI/CD Workflow:
Update your CI/CD pipeline to automatically append a 6-month expiration date to image tags that are not critical. This approach ensures that images are only retained as long as they are relevant, reducing manual cleanup efforts.