diff --git a/pkg/provider/azure_standard.go b/pkg/provider/azure_standard.go index a995e33bc7..7af37cf032 100644 --- a/pkg/provider/azure_standard.go +++ b/pkg/provider/azure_standard.go @@ -368,8 +368,6 @@ func (az *Cloud) serviceOwnsFrontendIP(fip network.FrontendIPConfiguration, serv return true, isPrimaryService, nil } klog.V(4).Infof("serviceOwnsFrontendIP: the public IP with ID %s is being referenced by other service with public IP address %s", *pip.ID, *pip.IPAddress) - - return false, isPrimaryService, nil } return false, isPrimaryService, nil diff --git a/pkg/provider/azure_standard_test.go b/pkg/provider/azure_standard_test.go index 244c598b57..5bc857cdbf 100644 --- a/pkg/provider/azure_standard_test.go +++ b/pkg/provider/azure_standard_test.go @@ -1628,6 +1628,33 @@ func TestServiceOwnsFrontendIP(t *testing.T) { }, }, }, + { + desc: "serviceOwnsFrontendIP should return false if there is no public IP address in the frontend IP config", + existingPIPs: []network.PublicIPAddress{ + { + ID: to.StringPtr("pip"), + PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{ + IPAddress: to.StringPtr("4.3.2.1"), + }, + }, + }, + fip: network.FrontendIPConfiguration{ + Name: to.StringPtr("auid"), + FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{ + PublicIPPrefix: &network.SubResource{ + ID: to.StringPtr("pip1"), + }, + }, + }, + service: &v1.Service{ + ObjectMeta: meta.ObjectMeta{ + UID: types.UID("secondary"), + }, + Spec: v1.ServiceSpec{ + LoadBalancerIP: "4.3.2.1", + }, + }, + }, { desc: "serviceOwnsFrontendIP should detect the secondary external service", existingPIPs: []network.PublicIPAddress{