Skip to content

Commit

Permalink
fix: do not tag user-assigned public IP
Browse files Browse the repository at this point in the history
  • Loading branch information
nilo19 authored and k8s-infra-cherrypick-robot committed Mar 11, 2023
1 parent b5bb401 commit 4b85e0c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,10 +999,10 @@ func (az *Cloud) ensurePublicIPExists(service *v1.Service, pipName string, domai

serviceName := getServiceName(service)

var changed bool
var changed, owns, isUserAssignedPIP bool
if existsPip {
// ensure that the service tag is good for managed pips
owns, isUserAssignedPIP := serviceOwnsPublicIP(service, &pip, clusterName)
owns, isUserAssignedPIP = serviceOwnsPublicIP(service, &pip, clusterName)
if owns && !isUserAssignedPIP {
changed, err = bindServicesToPIP(&pip, []string{serviceName}, false)
if err != nil {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ func (az *Cloud) ensurePublicIPExists(service *v1.Service, pipName string, domai
}
klog.V(2).Infof("ensurePublicIPExists for service(%s): pip(%s) - creating", serviceName, *pip.Name)
}
if az.ensurePIPTagged(service, &pip) {
if !isUserAssignedPIP && az.ensurePIPTagged(service, &pip) {
changed = true
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/provider/azure_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,31 @@ func TestEnsurePublicIPExists(t *testing.T) {
},
shouldPutPIP: true,
},
{
desc: "should not tag the user-assigned pip",
existingPIPs: []network.PublicIPAddress{
{
Name: pointer.String("pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
IPAddress: pointer.String("1.2.3.4"),
},
Tags: map[string]*string{"a": pointer.String("b")},
},
},
expectedPIP: &network.PublicIPAddress{
Name: pointer.String("pip1"),
Tags: map[string]*string{"a": pointer.String("b")},
ID: pointer.String("/subscriptions/subscription/resourceGroups/rg" +
"/providers/Microsoft.Network/publicIPAddresses/pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
PublicIPAddressVersion: network.IPv4,
IPAddress: pointer.String("1.2.3.4"),
},
},
additionalAnnotations: map[string]string{
consts.ServiceAnnotationAzurePIPTags: "a=c",
},
},
}

for _, test := range testCases {
Expand Down

0 comments on commit 4b85e0c

Please sign in to comment.