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: Get automatically created subnetwork if none is specified for auto network #57351

Merged
merged 1 commit into from
Dec 23, 2017

Conversation

nicksardo
Copy link
Contributor

Fixes #57350

Release note:

GCE: Fixes ILB creation on automatic networks with manually created subnetworks.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 18, 2017
@nicksardo
Copy link
Contributor Author

/unassign jsafrane
/assign bowei

@k8s-ci-robot k8s-ci-robot assigned bowei and unassigned jsafrane Dec 18, 2017
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)

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?

Copy link
Contributor Author

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) {
Copy link

@dividinglimits dividinglimits Dec 18, 2017

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)
  }

 ...
}

@nicksardo nicksardo force-pushed the auto-sub branch 4 times, most recently from 480acac to 4ce5d9f Compare December 19, 2017 18:41
@nicksardo nicksardo changed the title GCE: Get automatically created subnetwork if none is specified GCE: Get automatically created subnetwork if none is specified for auto network Dec 19, 2017
@nicksardo
Copy link
Contributor Author

/uncc dividinglimits
/cc @rramkumar1

@k8s-ci-robot
Copy link
Contributor

@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:

/uncc dividinglimits
/cc @rramkumar1

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
Copy link
Contributor

@rramkumar1 rramkumar1 Dec 20, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, thanks!

@rramkumar1
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@rramkumar1: changing LGTM is restricted to assignees, and only kubernetes org members may be assigned issues.

In response to this:

/lgtm

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.

@nicksardo
Copy link
Contributor Author

Thanks @rramkumar1
Ping @bowei for second look.

@nicksardo nicksardo force-pushed the auto-sub branch 2 times, most recently from 08f800b to f5d5231 Compare December 21, 2017 00:54
}

if len(autoSubnets) > 1 {
return "", fmt.Errorf("multiple subnetworks exist in auto CIDR")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in the same region"

Copy link
Contributor Author

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 {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@bowei bowei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 22, 2017
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@nicksardo
Copy link
Contributor Author

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Dec 23, 2017

@nicksardo: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce c893ce8 link /test pull-kubernetes-e2e-gce

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.

@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit 6937763 into kubernetes:master Dec 23, 2017
k8s-github-robot pushed a commit that referenced this pull request Jan 3, 2018
…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.
```
k8s-github-robot pushed a commit that referenced this pull request Jan 3, 2018
…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.
```
@nicksardo nicksardo deleted the auto-sub branch January 12, 2018 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants