Skip to content

Commit

Permalink
Merge pull request #394 from pdostal/gce_cleanup_images_ignore
Browse files Browse the repository at this point in the history
Implement pcw_ignore for cleanup_images in gce
  • Loading branch information
asmorodskyi committed Jul 16, 2024
2 parents d051d0c + b7162f5 commit 52a69d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ocw/lib/gce.py
Original file line number Diff line number Diff line change
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 52a69d3

Please sign in to comment.