-
Notifications
You must be signed in to change notification settings - Fork 543
fix/SafeLabel-Owner-GCP for Issue #6218 #6219
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
fa3c44a
81e50fd
3a5ca48
acb1caf
2440b80
6855c74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -925,13 +925,21 @@ def __init__(self, network_spec: GceNetworkSpec): | |
| self.is_existing_network = True | ||
| self.subnet_names = [] | ||
| self.primary_subnet_name = None | ||
| if network_spec.subnet_names: | ||
| self.subnet_names = network_spec.subnet_names | ||
| elif gcp_flags.GCE_NETWORK_NAMES.value: | ||
| self.subnet_names = gcp_flags.GCE_NETWORK_NAMES.value | ||
| self.network_name = None | ||
|
|
||
| # Determine the network name first | ||
| if gcp_flags.GCE_NETWORK_NAMES.value: | ||
| self.network_name = gcp_flags.GCE_NETWORK_NAMES.value[0] | ||
| else: | ||
| self.subnet_names = self._MakeGceNetworkName() | ||
| self.network_name = self._MakeGceNetworkName() | ||
| self.is_existing_network = False | ||
|
|
||
| # Then handle subnet names | ||
| if network_spec.subnet_names: | ||
| self.subnet_names = network_spec.subnet_names | ||
| elif not self.is_existing_network: | ||
| # If we're creating a new network, use the network name as subnet name by default | ||
| self.subnet_names = [self.network_name] | ||
| if not isinstance(self.subnet_names, list): | ||
| self.subnet_names = [self.subnet_names] | ||
| self.primary_subnet_name = self.subnet_names[0] | ||
|
|
@@ -940,28 +948,30 @@ def __init__(self, network_spec: GceNetworkSpec): | |
| self.subnet_resources = [] | ||
| mode = gcp_flags.GCE_NETWORK_TYPE.value | ||
| self.subnet_resource = None | ||
| # Create network resources using network_name | ||
| if not self.is_existing_network or mode == 'legacy': | ||
| for name in self.subnet_names: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to send this networking code in the same PR? It's not mentioned in the description at all & I'm not sure if we can safely delete subnet_names / replace it with only a singular network_name. I'd have to search through our callers to see if we set multiple anywhere (unless you can convince me the code for this is dead). Either way that's complicated enough it seems like a separate PR.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for catching that. I mixed another fix to this PR, so now cleaned up. |
||
| self.network_resources.append( | ||
| GceNetworkResource(name, mode, self.project, self.mtu) | ||
| ) | ||
| self.network_resources.append( | ||
| GceNetworkResource(self.network_name, mode, self.project, self.mtu) | ||
| ) | ||
|
|
||
| # Create subnet resources using subnet_names within the specified network | ||
| if (self.is_existing_network and mode != 'legacy') or (mode == 'custom'): | ||
| subnet_region = util.GetRegionFromZone(network_spec.zone) | ||
| for name in self.subnet_names: | ||
| self.subnet_resources.append( | ||
| GceSubnetResource( | ||
| name, name, subnet_region, self.cidr, self.project | ||
| name, self.network_name, subnet_region, self.cidr, self.project | ||
| ) | ||
| ) | ||
| self.subnet_resource = GceSubnetResource( | ||
| self.primary_subnet_name, | ||
| self.primary_subnet_name, | ||
| self.network_name, | ||
| subnet_region, | ||
| self.cidr, | ||
| self.project, | ||
| ) | ||
| self.network_resource = GceNetworkResource( | ||
| self.primary_subnet_name, mode, self.project, self.mtu | ||
| self.network_name, mode, self.project, self.mtu | ||
| ) | ||
| # Stage FW rules. | ||
| self.all_nets = self._GetNetworksFromSpec( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job finding the right place in code for this! Only comment is as below to call this method for all tags & not just owner.