Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure: Update the frontend IP config when the service's pipName annotation is changed #95813

Merged
merged 1 commit into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -531,6 +531,10 @@ func (az *Cloud) findServiceIPAddress(ctx context.Context, clusterName string, s
return service.Spec.LoadBalancerIP, nil
}

if len(service.Status.LoadBalancer.Ingress) > 0 && len(service.Status.LoadBalancer.Ingress[0].IP) > 0 {
return service.Status.LoadBalancer.Ingress[0].IP, nil
}

_, lbStatus, existsLb, err := az.getServiceLoadBalancer(service, clusterName, nil, false)
if err != nil {
return "", err
Expand Down Expand Up @@ -664,9 +668,7 @@ func (az *Cloud) ensurePublicIPExists(service *v1.Service, pipName string, domai
klog.V(2).Infof("service(%s): pip(%s) - creating as ipv4 for clusterIP:%v", serviceName, *pip.Name, service.Spec.ClusterIP)
}

klog.V(2).Infof("ensurePublicIPExists for service(%s): pip(%s) - creating", serviceName, *pip.Name)

klog.V(10).Infof("CreateOrUpdatePIP(%s, %q): start", pipResourceGroup, *pip.Name)
klog.V(2).Infof("CreateOrUpdatePIP(%s, %q): start", pipResourceGroup, *pip.Name)
err = az.CreateOrUpdatePIP(service, pipResourceGroup, pip)
if err != nil {
klog.V(2).Infof("ensure(%s) abort backoff: pip(%s)", serviceName, *pip.Name)
Expand Down Expand Up @@ -835,9 +837,6 @@ func (az *Cloud) isFrontendIPChanged(clusterName string, config network.Frontend
}
return config.PrivateIPAllocationMethod != network.Static || !strings.EqualFold(loadBalancerIP, to.String(config.PrivateIPAddress)), nil
}
if loadBalancerIP == "" {
return false, nil
}
pipName, _, err := az.determinePublicIPName(clusterName, service)
if err != nil {
return false, err
Expand Down Expand Up @@ -1212,7 +1211,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
ID: to.StringPtr(fmt.Sprintf(frontendIPConfigIDTemplate, az.SubscriptionID, az.ResourceGroup, *lb.Name, defaultLBFrontendIPConfigName)),
FrontendIPConfigurationPropertiesFormat: fipConfigurationProperties,
})
klog.Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - adding", serviceName, wantLb, defaultLBFrontendIPConfigName)
klog.V(2).Infof("reconcileLoadBalancer for service (%s)(%t): lb frontendconfig(%s) - adding", serviceName, wantLb, defaultLBFrontendIPConfigName)
dirtyConfigs = true
}
}
Expand Down
Expand Up @@ -1373,20 +1373,6 @@ func TestIsFrontendIPChanged(t *testing.T) {
expectedFlag: true,
expectedError: false,
},
{
desc: "isFrontendIPChanged shall return false if no loadbalancerIP is given",
config: network.FrontendIPConfiguration{
Name: to.StringPtr("btest1-name"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PrivateIPAllocationMethod: network.IPAllocationMethod("static"),
PrivateIPAddress: to.StringPtr("1.1.1.2"),
},
},
lbFrontendIPConfigName: "btest1-name",
service: getTestService("test1", v1.ProtocolTCP, nil, false, 80),
expectedFlag: false,
expectedError: false,
},
{
desc: "isFrontendIPChanged shall return false if config.PublicIPAddress == nil",
config: network.FrontendIPConfiguration{
Expand Down