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

[release-1.26] fix: do not tag user-assigned public IP #3531

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
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