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 30, 2023
1 parent 0e60846 commit 11f75c0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 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,25 +104,27 @@ 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)
deleted_content.append(unit)

if not arc_tasks or \
any([t for t in arc_tasks
if len(t.units) < UNASSOCIATE_BATCH_LIMIT]):
if not arc_tasks or 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 11f75c0

Please sign in to comment.