Merge "Fix exception in image cleanup"

This commit is contained in:
Zuul 2025-04-14 08:02:08 +00:00 committed by Gerrit Code Review
commit 6155ca0543

View File

@ -430,20 +430,25 @@ class CleanupWorker(BaseWorker):
'''
images_dir = self._config.images_dir
diskimage = self._config.diskimages.get(image_name)
if not diskimage.delete_after_upload:
return
to_keep = set(diskimage.keep_image_types)
# Examine the currently uploaded images and determine which
# formats need to be kept for future uploads.
for provider in providers:
if not provider.manage_images:
continue
if image_name not in provider.diskimages:
continue
upload = self._zk.getMostRecentBuildImageUploads(
1, image_name, build_id, provider.name, zk.READY)
if not upload:
to_keep.add(provider.image_type)
# If the diskimage is not in the config, it can be deleted.
if not diskimage:
to_keep = set()
else:
if not diskimage.delete_after_upload:
return
to_keep = set(diskimage.keep_image_types)
# Examine the currently uploaded images and determine which
# formats need to be kept for future uploads.
for provider in providers:
if not provider.manage_images:
continue
if image_name not in provider.diskimages:
continue
upload = self._zk.getMostRecentBuildImageUploads(
1, image_name, build_id, provider.name, zk.READY)
if not upload:
to_keep.add(provider.image_type)
base = "-".join([image_name, build_id])
files = DibImageFile.from_image_id(images_dir, base)