Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 24, 2023
1 parent 096eaf3 commit 0fd405a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pubtools/_pulp/tasks/garbage_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 0fd405a

Please sign in to comment.