Skip to content

Commit

Permalink
Remove garbage collect batching [RHELDST-20725]
Browse files Browse the repository at this point in the history
During QA testing we found a bug in the Pulp API which means that
batching will not work. This change should be removed until the bug in
the Pulp API has been resolved.
  • Loading branch information
amcmahon-rh committed Nov 6, 2023
1 parent 8259493 commit f2912e9
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions pubtools/_pulp/tasks/garbage_collect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import logging
from datetime import datetime, timedelta

Expand All @@ -11,8 +10,6 @@
LOG = logging.getLogger("pubtools.pulp")
step = PulpTask.step

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 @@ -99,24 +96,13 @@ def clean_all_rpm_content(self):
LOG.info("No repos found for cleaning.")
return
arc_repo = clean_repos[0]

deleted_arc = list(arc_repo.remove_content(criteria=criteria))
deleted_content = []

while True:
deletion_tasks = arc_repo.remove_content(
criteria=criteria, limit=UNASSOCIATE_BATCH_LIMIT
).result()
arc_tasks = [t for t in deletion_tasks if t.repo_id == "all-rpm-content"]
for task in arc_tasks:
for task in deleted_arc:
if task.repo_id == "all-rpm-content":
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]
):
break

if not deleted_content:
LOG.info("No all-rpm-content found older than %s", arc_threshold)

Expand Down

0 comments on commit f2912e9

Please sign in to comment.