Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCE: Add 'tf-network' to the list of protected networks #328

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ocw/lib/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from os.path import basename
from datetime import timezone
from dateutil.parser import parse
from webui.PCWConfig import ConfigFile
import googleapiclient.discovery
from googleapiclient.errors import HttpError
from google.oauth2 import service_account
Expand All @@ -11,7 +12,6 @@

class GCE(Provider):
__instances = {}
__skip_networks = frozenset({"default"})

def __new__(cls, namespace):
if namespace not in GCE.__instances:
Expand All @@ -20,6 +20,9 @@ def __new__(cls, namespace):

def __init__(self, namespace):
super().__init__(namespace)

self.__skip_networks = frozenset(ConfigFile().getList('cleanup/gce-skip-networks', ["default"]))

self.__compute_client = None
self.private_key_data = self.get_data()
self.project = self.private_key_data["project_id"]
Expand Down
3 changes: 3 additions & 0 deletions templates/pcw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ to = <[email protected]>
[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
Expand Down
Loading