-
Notifications
You must be signed in to change notification settings - Fork 40k
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: Get automatically created subnetwork if none is specified for auto network #57351
Conversation
/unassign jsafrane |
func determineSubnetURL(service *compute.Service, networkProjectID, networkName, region string) (string, bool, error) { | ||
n, err := getNetwork(service, networkProjectID, networkName) | ||
if err != nil { | ||
return "", false, fmt.Errorf("eould not retrieve network %q in attempt to determine if legacy network or see list of subnets; err: %v", networkName, err) |
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.
what does "eould" mean in this context?
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.
Typo.
@@ -499,6 +487,32 @@ func CreateGCECloud(config *CloudConfig) (*GCECloud, error) { | |||
return gce, nil | |||
} | |||
|
|||
func determineSubnetURL(service *compute.Service, networkProjectID, networkName, region string) (string, bool, error) { |
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.
Under what circumstance would a return of (string, error) not be sufficient to provide the necessary data? It returns either an error, or a subnet, but never both.
const (
ErrNoNetwork = fmt.Errorf("eould not retrieve network %q in attempt to determine if legacy network or see list of subnets; err: %v", networkName, err)
ErrLegacyNetwork = fmt.Errorf("Determined network %q is of type legacy.", networkName")
ErrSubnetList = fmt.Errorf("error listing subnets of network %q within region %v. err: %v", networkName, region, err)
ErrNoAutoSubnets = fmt.Errorf("could not find any auto subnet in region %q within list %+v", region, subnets)
)
...
[line 442] subnetURL, err = determineSubnetURL(service, netProjID, networkName, config.Region)
if _, ok := err.(ErrLegacyNetwork); ok {
// Gracefully fail because kubelet calls CreateGCECloud without any config, and API calls will fail coming from minions.
glog.Warningf("Could not retrieve network %q in attempt to determine if legacy network or see list of subnets, err %v", networkURL, err)
glog.Warning(err)
}
...
}
480acac
to
4ce5d9f
Compare
/uncc dividinglimits |
@nicksardo: GitHub didn't allow me to request PR reviews from the following users: rramkumar1. Note that only kubernetes members can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
// subnetsInAutoCIDR takes a list of subnets for a single region and | ||
// returns subnets which exists in the auto CIDR range. | ||
func subnetsInAutoCIDR(subnets []*compute.Subnetwork) ([]*compute.Subnetwork, error) { | ||
var res []*compute.Subnetwork |
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.
I would suggest changing the signature of the function to take in a CIDR range and change the function name to something like subnetsInCIDR(). This would make the function more generic and fix the issue we discussed offline regarding returning a list.
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.
Good call, thanks!
/lgtm |
@rramkumar1: changing LGTM is restricted to assignees, and only kubernetes org members may be assigned issues. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Thanks @rramkumar1 |
08f800b
to
f5d5231
Compare
} | ||
|
||
if len(autoSubnets) > 1 { | ||
return "", fmt.Errorf("multiple subnetworks exist in auto CIDR") |
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.
"in the same region"
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.
Done.
) | ||
|
||
func typeOfNetwork(network *compute.Network) netType { | ||
if len(network.IPv4Range) > 0 { |
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.
[minor] I find network.IPv4Range != ""
to be easier to read
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.
Done.
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, nicksardo, rramkumar1 Associated issue: #57350 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test pull-kubernetes-e2e-kops-aws |
/test all [submit-queue is verifying that this PR is safe to merge] |
@nicksardo: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 57351, 55654). If you want to cherry-pick this change to another branch, please follow the instructions here. |
…351-upstream-release-1.9 Automatic merge from submit-queue. Automated cherry pick of #57351: Get automatically created subnetwork if none is specified Cherry pick of #57351 on release-1.9. #57351: Get automatically created subnetwork if none is specified **Release note**: ```release-note GCE: Fixes ILB creation on automatic networks with manually created subnetworks. ```
…351-upstream-release-1.8 Automatic merge from submit-queue. Automated cherry pick of #57351: Get automatically created subnetwork if none is specified Cherry pick of #57351 on release-1.8. #57351: Get automatically created subnetwork if none is specified **Release note**: ```release-note GCE: Fixes ILB creation on automatic networks with manually created subnetworks. ```
Fixes #57350
Release note: