From 0fd405ad82c9d40a3c70239fe70dc29ddf01f989 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:40:53 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pubtools/_pulp/tasks/garbage_collect.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pubtools/_pulp/tasks/garbage_collect.py b/pubtools/_pulp/tasks/garbage_collect.py index 06814e44..9ffcd68f 100644 --- a/pubtools/_pulp/tasks/garbage_collect.py +++ b/pubtools/_pulp/tasks/garbage_collect.py @@ -11,8 +11,8 @@ LOG = logging.getLogger("pubtools.pulp") step = PulpTask.step -UNASSOCIATE_BATCH_LIMIT = int( - os.getenv("PULP_GC_UNASSOCIATE_BATCH_LIMIT", "10000")) +UNASSOCIATE_BATCH_LIMIT = int(os.getenv("PULP_GC_UNASSOCIATE_BATCH_LIMIT", "10000")) + class GarbageCollect(PulpClientService, PulpTask): """Perform garbage collection on Pulp data. @@ -104,11 +104,14 @@ def clean_all_rpm_content(self): while True: delete_arc_tasks = list( - arc_repo.remove_content(criteria=criteria, - limit=UNASSOCIATE_BATCH_LIMIT) + arc_repo.remove_content( + criteria=criteria, limit=UNASSOCIATE_BATCH_LIMIT + ) ) # The pulp client returns task(s) wrapped in a list - arc_tasks = list(filter(lambda x: x.repo_id == "all-rpm-content", delete_arc_tasks)) + arc_tasks = list( + filter(lambda x: x.repo_id == "all-rpm-content", delete_arc_tasks) + ) for task in arc_tasks: for unit in task.units: LOG.info("Old all-rpm-content deleted: %s", unit.name) @@ -117,14 +120,14 @@ def clean_all_rpm_content(self): # Assuming the client can return multiple (python) tasks. # If all tasks delete less units than the batch limit, # implying all relevant units have been unassociated. - if not arc_tasks or \ - not any([t for t in arc_tasks - if len(t.units) < UNASSOCIATE_BATCH_LIMIT]): + if not arc_tasks or not any( + [t for t in arc_tasks if len(t.units) < UNASSOCIATE_BATCH_LIMIT] + ): break if not deleted_content: - LOG.info("No all-rpm-content found older than %s", - arc_threshold) + LOG.info("No all-rpm-content found older than %s", arc_threshold) + def entry_point(): with GarbageCollect() as instance: