From c69cea41a074b29960e7e2fc25b29d16890fbd07 Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Fri, 20 Apr 2018 09:48:33 +0800 Subject: [PATCH] Check all backends for vmss and standard instances --- .../providers/azure/azure_standard.go | 16 ++++++++------- .../providers/azure/azure_vmss.go | 20 ++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg/cloudprovider/providers/azure/azure_standard.go b/pkg/cloudprovider/providers/azure/azure_standard.go index 02c7c103a34..179ee7839dd 100644 --- a/pkg/cloudprovider/providers/azure/azure_standard.go +++ b/pkg/cloudprovider/providers/azure/azure_standard.go @@ -630,13 +630,15 @@ func (as *availabilitySet) ensureHostInPool(serviceName string, nodeName types.N // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain // about this. - backendPool := *newBackendPools[0].ID - matches := backendPoolIDRE.FindStringSubmatch(backendPool) - if len(matches) == 2 { - lbName := matches[1] - if strings.HasSuffix(lbName, InternalLoadBalancerNameSuffix) == isInternal { - glog.V(4).Infof("Node %q has already been added to LB %q, omit adding it to a new one", nodeName, lbName) - return nil + for _, pool := range newBackendPools { + backendPool := *pool.ID + matches := backendPoolIDRE.FindStringSubmatch(backendPool) + if len(matches) == 2 { + lbName := matches[1] + if strings.HasSuffix(lbName, InternalLoadBalancerNameSuffix) == isInternal { + glog.V(4).Infof("Node %q has already been added to LB %q, omit adding it to a new one", nodeName, lbName) + return nil + } } } } diff --git a/pkg/cloudprovider/providers/azure/azure_vmss.go b/pkg/cloudprovider/providers/azure/azure_vmss.go index 65fcfd2fe88..5096dd01125 100644 --- a/pkg/cloudprovider/providers/azure/azure_vmss.go +++ b/pkg/cloudprovider/providers/azure/azure_vmss.go @@ -627,13 +627,15 @@ func (ss *scaleSet) ensureHostsInVMSetPool(serviceName string, backendPoolID str // the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain // about this. - backendPool := *newBackendPools[0].ID - matches := backendPoolIDRE.FindStringSubmatch(backendPool) - if len(matches) == 2 { - lbName := matches[1] - if strings.HasSuffix(lbName, InternalLoadBalancerNameSuffix) == isInternal { - glog.V(4).Infof("vmss %q has already been added to LB %q, omit adding it to a new one", vmSetName, lbName) - return nil + for _, pool := range newBackendPools { + backendPool := *pool.ID + matches := backendPoolIDRE.FindStringSubmatch(backendPool) + if len(matches) == 2 { + lbName := matches[1] + if strings.HasSuffix(lbName, InternalLoadBalancerNameSuffix) == isInternal { + glog.V(4).Infof("vmss %q has already been added to LB %q, omit adding it to a new one", vmSetName, lbName) + return nil + } } } } @@ -696,7 +698,7 @@ func (ss *scaleSet) EnsureHostsInPool(serviceName string, nodes []*v1.Node, back for ssName, instanceIDs := range scalesets { // Only add nodes belonging to specified vmSet to basic LB backends. - if !ss.useStandardLoadBalancer() && ssName != vmSetName { + if !ss.useStandardLoadBalancer() && !strings.EqualFold(ssName, vmSetName) { continue } @@ -859,7 +861,7 @@ func (ss *scaleSet) EnsureBackendPoolDeleted(poolID, vmSetName string, backendAd for ssName := range scalesets { // Only remove nodes belonging to specified vmSet to basic LB backends. - if !ss.useStandardLoadBalancer() && ssName != vmSetName { + if !ss.useStandardLoadBalancer() && !strings.EqualFold(ssName, vmSetName) { continue }