diff --git a/ocw/lib/gce.py b/ocw/lib/gce.py index 95cc85cb..89249718 100644 --- a/ocw/lib/gce.py +++ b/ocw/lib/gce.py @@ -187,9 +187,14 @@ def cleanup_images(self) -> None: self.log_dbg(f"{len(images)} images found") for image in images: if self.is_outdated(parse(image["creationTimestamp"]).astimezone(timezone.utc)): - self._delete_resource( - self.compute_client().images, image["name"], project=self.project, image=image["name"] - ) + labels = image.get('labels', []) + pcw_ignore_tag = 'pcw_ignore' in labels + if pcw_ignore_tag: + self.log_dbg(f"Ignoring {image['name']} due to 'pcw_ignore' label set to '1'") + else: + self._delete_resource( + self.compute_client().images, image["name"], project=self.project, image=image["name"] + ) def cleanup_firewalls(self) -> None: self.log_dbg("Firewalls cleanup")