Skip to content

Commit d99bd81

Browse files
committed
Fix panic when errors are nil
1 parent 661e4d5 commit d99bd81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (az *Cloud) CreateOrUpdateSecurityGroup(service *v1.Service, sg network.Sec
202202
}
203203

204204
// Invalidate the cache because another new operation has canceled the current request.
205-
if strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) {
205+
if err != nil && strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) {
206206
az.nsgCache.Delete(*sg.Name)
207207
}
208208

@@ -265,7 +265,7 @@ func (az *Cloud) CreateOrUpdateLB(service *v1.Service, lb network.LoadBalancer)
265265
az.lbCache.Delete(*lb.Name)
266266
}
267267
// Invalidate the cache because another new operation has canceled the current request.
268-
if strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) {
268+
if err != nil && strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) {
269269
az.lbCache.Delete(*lb.Name)
270270
}
271271
return err
@@ -645,7 +645,7 @@ func (az *Cloud) UpdateVmssVMWithRetry(resourceGroupName string, VMScaleSetName
645645
resp, err := az.VirtualMachineScaleSetVMsClient.Update(ctx, resourceGroupName, VMScaleSetName, instanceID, parameters, source)
646646
klog.V(10).Infof("UpdateVmssVMWithRetry: VirtualMachineScaleSetVMsClient.Update(%s,%s): end", VMScaleSetName, instanceID)
647647

648-
if strings.Contains(err.Error(), vmssVMNotActiveErrorMessage) {
648+
if err != nil && strings.Contains(err.Error(), vmssVMNotActiveErrorMessage) {
649649
// When instances are under deleting, updating API would report "not an active Virtual Machine Scale Set VM instanceId" error.
650650
// Since they're under deleting, we shouldn't send more update requests for it.
651651
klog.V(3).Infof("UpdateVmssVMWithRetry: VirtualMachineScaleSetVMsClient.Update(%s,%s) gets error message %q, abort backoff because it's probably under deleting", VMScaleSetName, instanceID, vmssVMNotActiveErrorMessage)

0 commit comments

Comments
 (0)