Skip to content

Commit 83977e5

Browse files
committed
Update handle-image-data command to report truly broken manifests
1 parent dd22662 commit 83977e5

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

pulp_container/app/management/commands/container-handle-image-data.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Command(BaseCommand):
3434

3535
def handle(self, *args, **options):
3636
manifests_updated_count = 0
37+
self._broken_manifests = []
3738

3839
manifests_v1 = Manifest.objects.filter(
3940
Q(media_type=MEDIA_TYPE.MANIFEST_V1),
@@ -68,6 +69,13 @@ def handle(self, *args, **options):
6869
self.style.SUCCESS("Successfully updated %d manifests." % manifests_updated_count)
6970
)
7071

72+
if self._broken_manifests:
73+
self.stdout.write(
74+
self.style.WARNING("Found %d broken manifests. PKs:" % len(self._broken_manifests))
75+
)
76+
for manifest in self._broken_manifests:
77+
self.stdout.write(self.style.WARNING(" %s" % manifest.pk))
78+
7179
if settings.CACHE_ENABLED and manifests_updated_count != 0:
7280
base_paths = ContainerDistribution.objects.values_list("base_path", flat=True)
7381
if base_paths:
@@ -91,11 +99,13 @@ def update_manifests(self, manifests_qs):
9199
]
92100

93101
for manifest in manifests_qs.iterator():
94-
# suppress non-existing/already migrated artifacts and corrupted JSON files
95-
with suppress(ObjectDoesNotExist, JSONDecodeError):
102+
try:
96103
needs_update = self.init_manifest(manifest)
97-
if needs_update:
98-
manifests_to_update.append(manifest)
104+
except (ObjectDoesNotExist, JSONDecodeError):
105+
self._broken_manifests.append(manifest)
106+
continue
107+
if needs_update:
108+
manifests_to_update.append(manifest)
99109

100110
if len(manifests_to_update) > 1000:
101111
manifests_qs.model.objects.bulk_update(

0 commit comments

Comments
 (0)