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

Fix nil pointer dereference in cloud_cidr_allocator. #57761

Closed
wants to merge 1 commit into from

Conversation

Dirbaio
Copy link
Contributor

@Dirbaio Dirbaio commented Jan 2, 2018

This PR fixes a nil pointer dereference that can happen when you run kube-controller-manager with --cidr-allocator-type=CloudAllocator and there are nodes where the cloud provider can't get the alias ranges for whatever reason.

This happened to me when switching my GCE cluster from using cloud routes to IP aliases. I added the flag but I had some GCE instances without the IP alias configured.

Release note:

Fix nil pointer dereference when running controller-manager with --cidr-allocator-type=CloudAllocator

@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/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 2, 2018
@nikhita
Copy link
Member

nikhita commented Jan 4, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 4, 2018
@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 4, 2018

/retest

@@ -197,11 +197,21 @@ func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error {

cidrs, err := ca.cloud.AliasRanges(types.NodeName(nodeName))
if err != nil {
util.RecordNodeStatusChange(ca.recorder, node, "CIDRNotAvailable")
node, err = ca.nodeLister.Get(nodeName)
Copy link
Member

Choose a reason for hiding this comment

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

can we combine the error cases into one block:

if err != nil || len(cidrs) == 0 {
  ....
}

Looks like the same code

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! The error is different though so it requires an extra if inside.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Dirbaio
We suggest the following additional approver: bowei

Assign the PR to them by writing /assign @bowei in a comment when ready.

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

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

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 6, 2018
@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 6, 2018

Rebased and squashed

@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 6, 2018

/retest

@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 11, 2018

Rebased and fixed the code so it doesn't overwrite err with the get node error.

/assign @bowei

@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 11, 2018

/retest

@bowei
Copy link
Member

bowei commented Jan 23, 2018

@jingax10 can you take a look?

@jingax10
Copy link
Contributor

@Dirbaio: sound like the issue is already fixed by #58186. Please confirm. Thanks!

@Dirbaio
Copy link
Contributor Author

Dirbaio commented Jan 31, 2018

I haven't actually tested to reproduce the error (it's quite involved) but the diff looks like it fixes the exact issue, yup.

Closing.

@Dirbaio Dirbaio closed this Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants