Skip to content

Commit

Permalink
Implement pcw_ignore for cleanup_images in gce
Browse files Browse the repository at this point in the history
  • Loading branch information
pdostal committed Jul 16, 2024
1 parent c827c97 commit 30e6476
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions ocw/lib/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ def cleanup_all(self) -> None:
self.log_info("Call cleanup_all")
if self.__bucket is not None:
self.cleanup_blobs()
self.cleanup_disks()
#self.cleanup_disks()
self.cleanup_images()
self.cleanup_firewalls()
self.cleanup_forwarding_rules()
self.cleanup_routes()
self.cleanup_subnetworks()
self.cleanup_networks()
#self.cleanup_firewalls()
#self.cleanup_forwarding_rules()
#self.cleanup_routes()
#self.cleanup_subnetworks()
#self.cleanup_networks()

def cleanup_blobs(self) -> None:
self.log_dbg("Blobs cleanup")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 30e6476

Please sign in to comment.