Skip to content
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

API Pagination misbehavior #3039

Closed
praiskup opened this issue Dec 1, 2023 · 2 comments · Fixed by #3256
Closed

API Pagination misbehavior #3039

praiskup opened this issue Dec 1, 2023 · 2 comments · Fixed by #3256
Assignees

Comments

@praiskup
Copy link
Member

praiskup commented Dec 1, 2023

I tried to cleanup tons of projects on our stage with a toy script

#! /bin/python3

import os
import sys
from copr.v3.pagination import next_page
from copr.v3 import Client


def _main():
    # Create an API client from config file
    config = os.path.join(os.path.expanduser("~"), ".config", sys.argv[1])

    print(f"Loading config: {config}")
    client = Client.create_from_config_file(path=config)

    owners = ["praiskup", "@copr"]

    for owner in owners:
        # Create a new project
        package_page = client.project_proxy.get_list(ownername=owner, pagination={"limit": 30})

        while package_page:
            for project in package_page:
                if "TEST" in project.name or "testmodule" in project.name:
                    print(f" DELETE: {owner}/{project.name}")
                    client.project_proxy.delete(owner, project.name)
                else:
                    print(f" no action: {owner}/{project.name}")
            package_page = next_page(package_page)


if __name__ == "__main__":
    _main()

Without creating new projects, I have to restart the script over and over, because it quits without removal of all the candidates:

$ copr-clean-projects copr
...
 DELETE: praiskup/module-testmodule-beakertest-20231130101020
 DELETE: praiskup/TEST1701339404695068111ExclusiveArch
 DELETE: praiskup/module-testmodulev2-beakertest-20231130101657
 DELETE: praiskup/module-testmodulev2-beakertest-20231130123819
 no action: @copr/test-mail
$ copr-clean-projects copr
...
 DELETE: praiskup/TEST1701249625504960770Project6
 DELETE: praiskup/TEST1701249625504960770Project7
 no action: @copr/test-mail
$ copr-clean-projects copr
...

@praiskup
Copy link
Member Author

praiskup commented Dec 1, 2023

One thing is that we skip many projects from the first owner (praiskup) but we skip immediately after going to the next owner (@copr). Edit: no, partly a false alarm, @copr only has a single project.

@nikromen nikromen added the doc label Dec 13, 2023
@nikromen
Copy link
Member

nikromen commented Dec 13, 2023

triage: document this behavior instead of fixing it

@nikromen nikromen moved this from Needs triage to In 3 months in CPT Kanban Dec 13, 2023
@praiskup praiskup moved this from In 3 months to In Progress in CPT Kanban Apr 29, 2024
@nikromen nikromen moved this from In Progress to Done in CPT Kanban May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants