-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage Image Overflow in our Quay.io Repository #843
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 80.20% 82.04% +1.83%
==========================================
Files 64 76 +12
Lines 4492 6092 +1600
==========================================
+ Hits 3603 4998 +1395
- Misses 600 747 +147
- Partials 289 347 +58
Flags with carried forward coverage won't be shown. Click here to find out more.
|
92eeb7c
to
125b3f0
Compare
Signed-off-by: dlaw4608 <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
…y label Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
Signed-off-by: KevFan <[email protected]>
dcc8f79
to
26b34d8
Compare
Signed-off-by: KevFan <[email protected]>
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.