Skip to content

Commit

Permalink
fis: only check the frontend IP config that is owned by the service
Browse files Browse the repository at this point in the history
  • Loading branch information
nilo19 committed Mar 24, 2022
1 parent b155ba8 commit c12a25c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
klog.V(2).Infof("reconcileLoadBalancer: reconcileLoadBalancer for service(%s): lb(%s) - updating", serviceName, lbName)
err := az.CreateOrUpdateLB(service, *lb)
if err != nil {
klog.Errorf("reconcileLoadBalancer for service(%s) abort backoff: lb(%s) - updating", serviceName, lbName)
klog.Errorf("reconcileLoadBalancer for service(%s) abort backoff: lb(%s) - updating: %s", serviceName, lbName, err.Error())
return nil, err
}

Expand Down Expand Up @@ -1683,6 +1683,12 @@ func (az *Cloud) reconcileFrontendIPConfigs(clusterName string, service *v1.Serv
)
for i := len(newConfigs) - 1; i >= 0; i-- {
config := newConfigs[i]
isServiceOwnsFrontendIP, _, _ := az.serviceOwnsFrontendIP(config, service)
if !isServiceOwnsFrontendIP {
klog.V(4).Infof("reconcileFrontendIPConfigs for service (%s): the frontend IP configuration %s does not belong to the service", serviceName, to.String(config.Name))
continue
}
klog.V(4).Infof("reconcileFrontendIPConfigs for service (%s): checking owned frontend IP cofiguration %s", serviceName, to.String(config.Name))
isFipChanged, err = az.isFrontendIPChanged(clusterName, config, service, defaultLBFrontendIPConfigName)
if err != nil {
return nil, false, err
Expand All @@ -1693,6 +1699,7 @@ func (az *Cloud) reconcileFrontendIPConfigs(clusterName string, service *v1.Serv
dirtyConfigs = true
previousZone = config.Zones
}
break
}

ownedFIPConfig, _, err = az.findFrontendIPConfigOfService(&newConfigs, service)
Expand Down
9 changes: 9 additions & 0 deletions pkg/provider/azure_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4612,6 +4612,15 @@ func TestReconcileZonesForFrontendIPConfigs(t *testing.T) {
consts.ServiceAnnotationLoadBalancerInternalSubnet: "subnet",
consts.ServiceAnnotationLoadBalancerInternal: consts.TrueAnnotationValue}, 80),
existingFrontendIPConfigs: []network.FrontendIPConfiguration{
{
Name: to.StringPtr("not-this-one"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
Subnet: &network.Subnet{
Name: to.StringPtr("subnet-1"),
},
},
Zones: &[]string{"2"},
},
{
Name: to.StringPtr("atest1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/azure_standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ func (az *Cloud) serviceOwnsFrontendIP(fip network.FrontendIPConfiguration, serv
var isPrimaryService bool
baseName := az.GetLoadBalancerName(context.TODO(), "", service)
if strings.HasPrefix(to.String(fip.Name), baseName) {
klog.V(6).Infof("serviceOwnsFrontendIP: found primary service %s of the "+
"frontend IP config %s", service.Name, *fip.Name)
klog.V(6).Infof("serviceOwnsFrontendIP: found primary service %s of the frontend IP config %s", service.Name, *fip.Name)
isPrimaryService = true
return true, isPrimaryService, nil
}
Expand Down

0 comments on commit c12a25c

Please sign in to comment.