-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Perform actions after a package was removed #22810
base: main
Are you sure you want to change the base?
Conversation
I do have to say, the current architecture looks pretty error-prone: I think at the moment, you're the only one who really knows what's happening where inside the registry-related code. |
Why doesn't the packages_service run the cleanup function itself? Isn't it fragile to expect callers of packages_service.Remove... to remember to do the cleanup? |
We must distinguish between two different deletion modes: The first is specified by the package type registry api. If there is a designated delete method there is no problem because the deletion of package is an intended operation. The second is our custom delete operation from the UI or API. This operation is not covered by the package type specification. Most package types are ok with this because the client just queries the available packages and now there is one missing, everything fine. But there are also package types where it is not possible to generate such query responses on the fly. An example is the Cargo registry which stores the package index in a git repository. If a package gets deleted from the UI/API the git repository must be changed too, otherwise the repository is out of sync with the db. Currently there is only a note in the Gitea documentation what to do in this case. So this PR is only needed for the second unsupported case. There are only 4 places where such logic is needed. Deletion from the package UI, deletion from the admin UI, deletion from the package API (Gitea API, not the registry API) and deletion by a cleanup rule.
That's a naïve view of how most package registries work and only a few will fit in. The common "interface" all registries (except the uploading of container images) use, are the methods in
I will add a readme file for future developers to explain how everything works together. (We should have more of these rough overviews of how things work in Gitea. But there should not be to much detail so they are not outdated shortly after.) As seen in #20751 (comment) it looks like the interface is well thought out, otherwise it would not have been possible to add a new package type without asking questions.
I thought of multiple ways on how to implement it. The first guess is to add it into |
As announced in #22810 I added a readme file to help understanding how the package registry archictecture works and how the go packages are related.
…-post-package-removal
…-post-package-removal
…-post-package-removal
…-post-package-removal
Can we have some tests? |
The removal of packages outside of the defined package registry flow may lead to dirty data if the package type stores informations about the available packages outside of the database. For example the Cargo registry stores the package index in a git repository. At the moment the owner needs to rebuild the whole index in this case from the user settings.
This PR enforces an update of the index entry in the git repository. In future the Debian registry will need this too.