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: panic in vmss cache conversion #2771
fix: panic in vmss cache conversion #2771
Conversation
✅ Deploy Preview for kubernetes-sigs-cloud-provide-azure canceled.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3fe5caf
to
0b58584
Compare
Do you think we should fix in cache side instead?E.g. add an extra return value for get function |
@@ -223,7 +223,8 @@ func (ss *ScaleSet) DetachDisk(ctx context.Context, nodeName types.NodeName, dis | |||
// Update the cache with the updated result only if its not nil | |||
// and contains the VirtualMachineScaleSetVMProperties | |||
if updateResult != nil && updateResult.VirtualMachineScaleSetVMProperties != nil { | |||
if updErr := ss.updateCache(vmName, nodeResourceGroup, vm.VMSSName, vm.InstanceID, updateResult); updErr != nil { | |||
if err := ss.updateCache(vmName, nodeResourceGroup, vm.VMSSName, vm.InstanceID, updateResult); err != nil { | |||
klog.Errorf("updateCache(%s, %s, %s) failed with error: %v", vmName, nodeResourceGroup, vm.VMSSName, vm.InstanceID, 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.
%s instead %v for 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's the diff? we use %v for printing err everywhere in this repo
pkg/provider/azure_vmss.go
Outdated
@@ -1690,6 +1702,9 @@ func (ss *ScaleSet) ensureBackendPoolDeletedFromVMSS(backendPoolID, vmSetName st | |||
klog.Errorf("ensureBackendPoolDeletedFromVMSS: failed to get vmss uniform from cache: %v", err) | |||
return err | |||
} | |||
if cachedUniform == nil { |
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.
no unit test for this package? :)
@MartinForReal if cache is nil, then return nil pointer error, I think that would make the PR more clear. |
@MartinForReal actually we allow nil cache in timedCache functions: cloud-provider-azure/pkg/cache/azure_cache_test.go Lines 79 to 82 in 3aa5ada
If we return nil cache error in timedCache Get function, that would make fundamental changes, I tend to only fix this issue in csi driver related functions, that would be safer. |
revert revert
dc1690a
to
faa26f7
Compare
/lgtm |
What type of PR is this?
/kind bug
What this PR does / why we need it:
fix: panic in cache conversion
This PR also check all cache conversion places, and fix panic if there is nil cache.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: