-
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
Fix nil pointer dereference in cloud_cidr_allocator. #57761
Conversation
/ok-to-test |
/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) |
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.
can we combine the error cases into one block:
if err != nil || len(cidrs) == 0 {
....
}
Looks like the same code
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! The error is different though so it requires an extra if inside.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Dirbaio Assign the PR to them by writing No associated issue. Update pull-request body to add a reference to an issue, or get approval with 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 |
Rebased and squashed |
/retest |
Rebased and fixed the code so it doesn't overwrite /assign @bowei |
/retest |
@jingax10 can you take a look? |
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. |
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: