Merge pull request #105666 from nilo19/fix/cherry-pick-842

fix: skip instance not found when decoupling vmss from lb
This commit is contained in:
Kubernetes Prow Robot 2021-10-19 13:10:24 -07:00 committed by GitHub
commit 421cdec3a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View File

@ -1492,11 +1492,11 @@ func (ss *scaleSet) ensureBackendPoolDeletedFromVMSS(service *v1.Service, backen
// When vmss is being deleted, CreateOrUpdate API would report "the vmss is being deleted" error.
// Since it is being deleted, we shouldn't send more CreateOrUpdate requests for it.
if vmss.ProvisioningState != nil && strings.EqualFold(*vmss.ProvisioningState, virtualMachineScaleSetsDeallocating) {
klog.V(3).Infof("ensureVMSSInPool: found vmss %s being deleted, skipping", vmssName)
klog.V(3).Infof("ensureBackendPoolDeletedFromVMSS: found vmss %s being deleted, skipping", vmssName)
continue
}
if vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations == nil {
klog.V(4).Infof("EnsureHostInPool: cannot obtain the primary network interface configuration, of vmss %s", vmssName)
klog.V(4).Infof("ensureBackendPoolDeletedFromVMSS: cannot obtain the primary network interface configuration, of vmss %s", vmssName)
continue
}
vmssNIC := *vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations
@ -1615,6 +1615,11 @@ func (ss *scaleSet) EnsureBackendPoolDeleted(service *v1.Service, backendPoolID,
continue
}
if errors.Is(err, cloudprovider.InstanceNotFound) {
klog.Infof("EnsureBackendPoolDeleted(%s): skipping ip config %s because the corresponding vmss vm is not found", getServiceName(service), ipConfigurationID)
continue
}
klog.Errorf("Failed to GetNodeNameByIPConfigurationID(%s): %v", ipConfigurationID, err)
allErrs = append(allErrs, err)
continue

View File

@ -2433,6 +2433,26 @@ func TestEnsureBackendPoolDeleted(t *testing.T) {
expectedErr: true,
vmClientErr: &retry.Error{RawError: fmt.Errorf("error")},
},
{
description: "EnsureBackendPoolDeleted should skip the node that doesn't exist",
backendpoolID: testLBBackendpoolID0,
backendAddressPools: &[]network.BackendAddressPool{
{
ID: to.StringPtr(testLBBackendpoolID0),
BackendAddressPoolPropertiesFormat: &network.BackendAddressPoolPropertiesFormat{
BackendIPConfigurations: &[]network.InterfaceIPConfiguration{
{
Name: to.StringPtr("ip-1"),
ID: to.StringPtr("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss/virtualMachines/6/networkInterfaces/nic"),
},
},
},
},
{
ID: to.StringPtr(testLBBackendpoolID1),
},
},
},
}
for _, test := range testCases {
@ -2487,7 +2507,6 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
},
},
{
// this would fail
ID: to.StringPtr(testLBBackendpoolID2),
BackendAddressPoolPropertiesFormat: &network.BackendAddressPoolPropertiesFormat{
BackendIPConfigurations: &[]network.InterfaceIPConfiguration{
@ -2526,7 +2545,7 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
mockVMSSVMClient.EXPECT().UpdateVMs(gomock.Any(), ss.ResourceGroup, gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2)
backendpoolAddressIDs := []string{testLBBackendpoolID0, testLBBackendpoolID1, testLBBackendpoolID2}
testVMSSNames := []string{"vmss-0", "vmss-1", "vmss-0"}
testVMSSNames := []string{"vmss-0", "vmss-1", "vmss-2"}
testFunc := make([]func() error, 0)
for i, id := range backendpoolAddressIDs {
i := i