diff --git a/ocw/lib/gce.py b/ocw/lib/gce.py index 8d5bf817..c90de614 100644 --- a/ocw/lib/gce.py +++ b/ocw/lib/gce.py @@ -3,6 +3,7 @@ from os.path import basename from datetime import timezone from dateutil.parser import parse +from webui.PCWConfig import PCWConfig, ConfigFile import googleapiclient.discovery from googleapiclient.errors import HttpError from google.oauth2 import service_account @@ -11,7 +12,11 @@ class GCE(Provider): __instances = {} - __skip_networks = frozenset({"default"}) + + if PCWConfig.has('cleanup/gce-skip-networks'): + __skip_networks = frozenset(ConfigFile().getList('cleanup/gce-skip-networks')) + else: + __skip_networks = frozenset({"default"}) def __new__(cls, namespace): if namespace not in GCE.__instances: diff --git a/templates/pcw.ini b/templates/pcw.ini index 4bdd8008..00da39b1 100644 --- a/templates/pcw.ini +++ b/templates/pcw.ini @@ -31,6 +31,9 @@ to = <your_email@suse.com> [cleanup] # Max age of data storage resources ( used in EC2 only ) ec2-max-age-days = 1 +# The list of networks which themselves as well as their resources should not be cleaned up +# This is due to fact that netowrk and security resources in GCP don't have neither tags nor metadata +gce-skip-networks = default,tf-network # Max age of data storage resources ( used in Azure and GCE ) max-age-hours = 1 # Max age for images in Openstack