-
Notifications
You must be signed in to change notification settings - Fork 86
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
[help appreciated] Support multi arch packages / Solving "Manifest Unknown" error #189
Conversation
Typescript is also not my forte, but is your pseudo code assuming that it's only removing multi-arch packages that are untagged? Because if somebody was running it to keep only 5 remaining, it may want to remove tagged multi-arch packages, in which case we'd also want to remove the untagged parts too. What if, as a different approach, it just refuses to kill a tag if it's in use from a multi-arch image? So a user could still do two rounds:
Where the second round will make sure there's always only 25 tagged versions in the registry. And the first round will basically only keep the latest 25 untagged versions, but if it tries to delete an untagged version (say version 30) that's part of a multi-arch image that's laying around, then it will not delete version 30. What this would mean is that after running the first job, there could be over 25 leftover, but the ones over that 25 are all still in-use. What this would essentially be is at the beginning, querying every single image for the manifest, and if it contains manifests, then saving the manifests to an array. And then when deleting each untagged image, it would simply block and move on if the digest was in that array. |
…ny packages to retain (under minVersionsToKeep)
…ny packages to retain (under minVersionsToKeep)
Thank you for the thoughts, @emmahsax I have adjusted the code to support "minVersionsToKeep" and "numOldVersionsToDelete". My approach here was:
Still, it's pseudocode, and the piece I have no clue how to code it is the "subIds" list (essentially the manifest ids) in get-versions.ts. Update: I was able to query the github API to get the package versions. Example:
What I am missing here is the link to the other package ids (sub-package ids), which is visible when I navigate to the respective page via browser. Any idea how to get the sub-ids of 204488276 returned by an API call?
Any help appreciated - started a discussion here in the meantime |
Stopping development on this, since covered by this https://github.com/dataaxiom/ghcr-cleanup-action |
I have also been working on https://github.com/emmahsax/action-ghcr-prune. This is call-able like this: jobs:
delete-old-packages:
runs-on: ubuntu-latest
steps:
# Delete all tagged packages except `latest` and the last other 5 (so 6 tagged packages left over
# at the end). Also delete the untagged manifests of the tagged multi-arch packages that are deleted.
- name: Delete Old Tagged Packages
uses: emmahsax/action-ghcr-prune@main
with:
container: ${{ github.event.repository.name }}
dry-run: true
keep-last: 5
keep-tags-regexes: |
^latest$
organization: ${{ github.repository_owner }}
prune-tags-regexes: |
.+
remove-multi-platform: true
token: ${{ secrets.GITHUB_TOKEN }}
# After the first step finishes, then go through and delete all other untagged packages
# UNLESS they are a part of a multi-arch image that is left around from the first step.
- name: Delete Old Untagged Packages
uses: emmahsax/action-ghcr-prune@main
with:
container: ${{ github.event.repository.name }}
dry-run: true
keep-last: 0
organization: ${{ github.repository_owner }}
prune-untagged: true
token: ${{ secrets.GITHUB_TOKEN }} I would love though for this official action to eventually pick up multi-arch support :( |
Fixes #90
Hi @cwille97 , @takost
apologies for tagging you in this. I saw you have recently contributed to this project, and I was hoping that we can together solve the issue above.
The problem we want to solve is that for multi-architecture packages, the current "delete-package-versions" action does not work, since it kills the individual packages of the architectures, and keeping only the "parent" shell that points to the respective packages.
I have an idea how it could be fixed, and it does not seem to be crazy difficult conceptually.
Unfortunately gitActions and typescript are not my forte, and what I have prepared so far is a "pseudo code".
My idea would be that we enhance the code on two points:
It would be fantastic if you chimed in with your skills :)
Let me know what you think