diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go index afa9fe2db8ba..18bac93ec3ca 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go @@ -170,7 +170,7 @@ func (az *Cloud) CreateOrUpdateSecurityGroup(service *v1.Service, sg network.Sec } // Invalidate the cache because another new operation has canceled the current request. - if strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) { + if err != nil && strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) { az.nsgCache.Delete(*sg.Name) } @@ -232,7 +232,7 @@ func (az *Cloud) CreateOrUpdateLB(service *v1.Service, lb network.LoadBalancer) az.lbCache.Delete(*lb.Name) } // Invalidate the cache because another new operation has canceled the current request. - if strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) { + if err != nil && strings.Contains(strings.ToLower(err.Error()), operationCancledErrorMessage) { az.lbCache.Delete(*lb.Name) } return err