Fix the VMSS name and resource group name when updating VMSS for LoadBalancer backendPools.

This commit is contained in:
Pengfei Ni 2020-03-22 04:55:06 +00:00
parent c3d483bf76
commit 0cb5f3b11f

View File

@ -917,6 +917,7 @@ func getVmssAndResourceGroupNameByVMProviderID(providerID string) (string, strin
} }
func (ss *scaleSet) ensureVMSSInPool(service *v1.Service, nodes []*v1.Node, backendPoolID string, vmSetName string) error { func (ss *scaleSet) ensureVMSSInPool(service *v1.Service, nodes []*v1.Node, backendPoolID string, vmSetName string) error {
klog.V(2).Infof("ensureVMSSInPool: ensuring VMSS with backendPoolID %s", backendPoolID)
vmssNamesMap := make(map[string]bool) vmssNamesMap := make(map[string]bool)
// the standard load balancer supports multiple vmss in its backend while the basic sku doesn't // the standard load balancer supports multiple vmss in its backend while the basic sku doesn't
@ -926,7 +927,7 @@ func (ss *scaleSet) ensureVMSSInPool(service *v1.Service, nodes []*v1.Node, back
continue continue
} }
// in this scenario the vmSetName is an empty string and the name of vmss should be obtained from the provider IDs of nodes // in this scenario the vmSetName is an empty string and the name of vmss should be obtained from the provider IDs of nodes
vmssName, resourceGroupName, err := getVmssAndResourceGroupNameByVMProviderID(node.Spec.ProviderID) resourceGroupName, vmssName, err := getVmssAndResourceGroupNameByVMProviderID(node.Spec.ProviderID)
if err != nil { if err != nil {
klog.V(4).Infof("ensureVMSSInPool: found VMAS node %s, will skip checking and continue", node.Name) klog.V(4).Infof("ensureVMSSInPool: found VMAS node %s, will skip checking and continue", node.Name)
continue continue
@ -940,6 +941,7 @@ func (ss *scaleSet) ensureVMSSInPool(service *v1.Service, nodes []*v1.Node, back
vmssNamesMap[vmSetName] = true vmssNamesMap[vmSetName] = true
} }
klog.V(2).Infof("ensureVMSSInPool begins to update VMSS %v with backendPoolID %s", vmssNamesMap, backendPoolID)
for vmssName := range vmssNamesMap { for vmssName := range vmssNamesMap {
vmss, err := ss.getVMSS(vmssName, azcache.CacheReadTypeDefault) vmss, err := ss.getVMSS(vmssName, azcache.CacheReadTypeDefault)
if err != nil { if err != nil {