pkg/api: paginate all repos in DeleteProject --force#1011
Open
Priyanshubhartistm wants to merge 1 commit into
Open
pkg/api: paginate all repos in DeleteProject --force#1011Priyanshubhartistm wants to merge 1 commit into
Priyanshubhartistm wants to merge 1 commit into
Conversation
ListRepository was called once with no opts, so the Harbor API defaulted to page_size=10. Projects with more than 10 repos had only the first page deleted, causing DeleteProject to return 412. Replace the single call with a loop over pages of 100 until all repositories are deleted before attempting project deletion. Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ListRepositorywas called once with no pagination opts insideDeleteProject --force, so the Harbor API defaulted topage_size=10. Projects with more than 10 repositories had only the first page deleted, causing the subsequentDeleteProjectAPI call to return412 Precondition Failed- leaving remaining repositories orphaned.This fix replaces the single
ListRepositorycall with a paginated loop usingpage_size=100that advances page-by-page until all repositories are deleted, before attempting project deletion.Type of Change
Changes
ListRepositorycall with a paginated loop inDeleteProject(pkg/api/project_handler.go)page_size=100(API maximum) and increments page until fewer than 100 results are returned