Recently update on the cloud provider caused the builder-cron-openstack
job to break, which exposed a bug in our cleanup scripts.
Check the visibility and ownerid of the image before attempting to
remove and image.
Issue: RELENG-3239
Change-Id: I38098c45fe73e872f3ca96960f704f168d9c4596
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
def _remove_images_from_cloud(images, cloud):
print("Removing {} images from {}.".format(len(images), cloud.cloud_config.name))
+ project_info = cloud._get_project_info()
for image in images:
+
if image.is_protected:
- print("WARNING: Image {} is protected. Cannot remove...".format(image.name))
+ log.warning("Image {} is protected. Cannot remove...".format(image.name))
+ continue
+
+ if image.visibility == "shared":
+ log.warning("Image {} is shared. Cannot remove...".format(image.name))
+ continue
+
+ if project_info["id"] != image.owner:
+ log.warning(
+ "Image {} not owned by project {}. Cannot remove...".format(image.name, cloud.cloud_config.name)
+ )
continue
try:
--- /dev/null
+---
+fixes:
+ - |
+ Check image owner and visibility on image cleanup
+
+ Recently update on the cloud provider has caused the builder-cron-openstack
+ job to fail, and exposed a bug in our cleanup scripts.
+
+ Check the visibility and ownerid of the image before attempting to remove
+ and image.