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

fix: ignore the case when comparing azure tags in service annotation #791

Merged
merged 1 commit into from
Sep 3, 2021
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
8 changes: 7 additions & 1 deletion pkg/provider/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2673,8 +2673,14 @@ func (az *Cloud) ensurePIPTagged(service *v1.Service, pip *network.PublicIPAddre
if _, ok := service.Annotations[consts.ServiceAnnotationAzurePIPTags]; ok {
annotationTags = parseTags(service.Annotations[consts.ServiceAnnotationAzurePIPTags])
}

for k, v := range annotationTags {
configTags[k] = v
found, key := findKeyInMapCaseInsensitive(configTags, k)
if !found {
configTags[k] = v
} else if !strings.EqualFold(to.String(v), to.String(configTags[key])) {
configTags[key] = v
}
}

// include the cluster name and service names tags when comparing
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/azure_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4141,7 +4141,7 @@ func TestEnsurePIPTagged(t *testing.T) {
service := v1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
consts.ServiceAnnotationAzurePIPTags: "a=b,c=d,e=,=f,ghi",
consts.ServiceAnnotationAzurePIPTags: "A=b,c=d,e=,=f,ghi",
},
},
}
Expand Down Expand Up @@ -4172,7 +4172,7 @@ func TestEnsurePIPTagged(t *testing.T) {
assert.Equal(t, expectedPIP, pip)
})

t.Run("ensurePIPTagged should delete the old tags if tht SystemTags is set", func(t *testing.T) {
t.Run("ensurePIPTagged should delete the old tags if the SystemTags is set", func(t *testing.T) {
cloud.SystemTags = "a,foo"
expectedPIP := network.PublicIPAddress{
Tags: map[string]*string{
Expand Down