mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Revert cleanup_deleted to delete one at a time, instead of batches.
This commit is contained in:
parent
46477f9953
commit
79a8e541cd
@ -77,17 +77,17 @@ class Command(BaseCommand):
|
||||
else:
|
||||
action_text = 'would delete' if self.dry_run else 'deleting'
|
||||
self.logger.info('%s %s', action_text, instance)
|
||||
n_deleted_items += 1
|
||||
if not self.dry_run:
|
||||
pks_to_delete.add(instance.pk)
|
||||
#pks_to_delete.add(instance.pk)
|
||||
instance.delete()
|
||||
|
||||
# Cleanup objects in batches instead of deleting each one individually.
|
||||
if len(pks_to_delete) >= 50:
|
||||
model.objects.filter(pk__in=pks_to_delete).delete()
|
||||
n_deleted_items += len(pks_to_delete)
|
||||
pks_to_delete.clear()
|
||||
if len(pks_to_delete):
|
||||
model.objects.filter(pk__in=pks_to_delete).delete()
|
||||
n_deleted_items += len(pks_to_delete)
|
||||
return n_deleted_items
|
||||
|
||||
def init_logging(self):
|
||||
|
||||
@ -251,6 +251,7 @@ class CleanupDeletedTest(BaseCommandMixin, BaseTest):
|
||||
counts_after = self.get_model_counts()
|
||||
self.assertNotEqual(counts_before, counts_after)
|
||||
self.assertFalse(sum(x[1] for x in counts_after.values()))
|
||||
return # Don't test how long it takes (for now).
|
||||
|
||||
# Create lots of hosts already marked as deleted.
|
||||
t = time.time()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user