Skip to content

Commit

Permalink
fix: skip instance not found when decoupling vmss from lb
Browse files Browse the repository at this point in the history
  • Loading branch information
nilo19 committed Oct 13, 2021
1 parent 6bdd6e2 commit 0b7ba30
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/provider/azure_vmss.go
Expand Up @@ -1529,6 +1529,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
Expand Down
25 changes: 22 additions & 3 deletions pkg/provider/azure_vmss_test.go
Expand Up @@ -2424,6 +2424,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 {
Expand Down Expand Up @@ -2483,7 +2503,7 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
BackendIPConfigurations: &[]network.InterfaceIPConfiguration{
{
Name: to.StringPtr("ip-1"),
ID: to.StringPtr("/subscriptions/sub/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-0/virtualMachines/0/networkInterfaces/nic"),
ID: to.StringPtr("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-0/virtualMachines/0/networkInterfaces/nic"),
},
},
},
Expand Down Expand Up @@ -2526,8 +2546,7 @@ func TestEnsureBackendPoolDeletedConcurrently(t *testing.T) {
})
}
errs := utilerrors.AggregateGoroutines(testFunc...)
assert.Equal(t, 1, len(errs.Errors()))
assert.Equal(t, "instance not found", errs.Error())
assert.Nil(t, errs)
}

func TestGetNodeCIDRMasksByProviderID(t *testing.T) {
Expand Down

0 comments on commit 0b7ba30

Please sign in to comment.