Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --I recall that this issue was reported previously in It was fixed in the master back then with and it was cherry-picked into with However we still observe the same issue with the legacy azure cloud-controller-manager v1.19.9. legacy azure cloud controller-manager to be able to delete LoadBalancer when the underlying resource group is deleted. a LoadBalancer manually the underlying resource group the LoadBalancer created in step 1 sure that the deletion of the LoadBalancer fails Events of the Service: Kubernetes version (use ): v1.19.9 Cloud provider or hardware configuration: OS (e.g: ): Kernel (e.g. ): Install tools: Network plugin and version (if this is a network-related bug): Others:
/sig cloud-provider /area provider/azure /cc
Thanks for reporting the issue. It should be a bug inside cloud provider. /triage accepted

Discussion:
rgName := az.getLoadBalancerResourceGroup() allLBs, rerr := az.LoadBalancerClient.List(ctx, rgName) if rerr != nil { <ins> if rerr.IsNotFound() { return nil, nil } </ins> az.Event(service, v1.EventTypeWarning, "ListLoadBalancers", rerr.Error().Error()) klog.Errorf("LoadBalancerClient.List(%v) failure with err=%v", rgName, rerr) return nil, rerr.Error()

allPIPs, rerr := az.PublicIPAddressesClient.List(ctx, pipResourceGroup) if rerr != nil { <ins> if rerr.IsNotFound() { return nil, nil } </ins> az.Event(service, v1.EventTypeWarning, "ListPublicIPs", rerr.Error().Error()) klog.Errorf("PublicIPAddressesClient.List(%v) failure with err=%v", pipResourceGroup, rerr) return nil, rerr.Error()

ctrl := gomock.NewController(t) defer ctrl.Finish() <del> az := GetTestCloud(ctrl) mockLBClient := az.LoadBalancerClient.(*mockloadbalancerclient.MockInterface) mockLBClient.EXPECT().List(gomock.Any(), az.ResourceGroup).Return(nil, &retry.Error{HTTPStatusCode: http.StatusInternalServerError}) </del> <ins> tests := []struct { clientErr   *retry.Error expectedErr error }{ { clientErr:   &retry.Error{HTTPStatusCode: http.StatusInternalServerError}, expectedErr: fmt.Errorf("Retriable: false, RetryAfter: 0s, HTTPStatusCode: 500, RawError: <nil>"), }, { clientErr:   &retry.Error{HTTPStatusCode: http.StatusNotFound}, expectedErr: nil, }, } for _, test := range tests { az := GetTestCloud(ctrl) mockLBClient := az.LoadBalancerClient.(*mockloadbalancerclient.MockInterface) mockLBClient.EXPECT().List(gomock.Any(), az.ResourceGroup).Return(nil, test.clientErr) pips, err := az.ListLB(&v1.Service{}) assert.Equal(t, test.expectedErr, err) assert.Empty(t, pips) } </ins> <del> pips, err := az.ListLB(&v1.Service{}) assert.Equal(t, fmt.Errorf("Retriable: false, RetryAfter: 0s, HTTPStatusCode: 500, RawError: <nil>"), err) assert.Empty(t, pips) </del> } func TestListPIP(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() <del> az := GetTestCloud(ctrl) mockPIPClient := az.PublicIPAddressesClient.(*mockpublicipclient.MockInterface) mockPIPClient.EXPECT().List(gomock.Any(), az.ResourceGroup).Return(nil, &retry.Error{HTTPStatusCode: http.StatusInternalServerError}) </del> <ins> tests := []struct { clientErr   *retry.Error expectedErr error }{ { clientErr:   &retry.Error{HTTPStatusCode: http.StatusInternalServerError}, expectedErr: fmt.Errorf("Retriable: false, RetryAfter: 0s, HTTPStatusCode: 500, RawError: <nil>"), }, { clientErr:   &retry.Error{HTTPStatusCode: http.StatusNotFound}, expectedErr: nil, }, } for _, test := range tests { az := GetTestCloud(ctrl) mockPIPClient := az.PublicIPAddressesClient.(*mockpublicipclient.MockInterface) mockPIPClient.EXPECT().List(gomock.Any(), az.ResourceGroup).Return(nil, test.clientErr) </ins> <del> pips, err := az.ListPIP(&v1.Service{}, az.ResourceGroup) assert.Equal(t, fmt.Errorf("Retriable: false, RetryAfter: 0s, HTTPStatusCode: 500, RawError: <nil>"), err) assert.Empty(t, pips) </del> <ins> pips, err := az.ListPIP(&v1.Service{}, az.ResourceGroup) assert.Equal(t, test.expectedErr, err) assert.Empty(t, pips) } </ins> } func TestCreateOrUpdatePIP(t *testing.T) {