Skip to content

Commit

Permalink
fix: should update dns label if target pip already have one and its v…
Browse files Browse the repository at this point in the history
…alue is different

Signed-off-by: MartinForReal <fanshangxiang@gmail.com>
  • Loading branch information
MartinForReal committed Nov 4, 2022
1 parent c1dc961 commit 4354fec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/provider/azure_loadbalancer.go
Expand Up @@ -1191,7 +1191,8 @@ func reconcileDNSSettings(pip *network.PublicIPAddress, domainNameLabel, service
} else {
existingDNSLabel := pip.PublicIPAddressPropertiesFormat.DNSSettings.DomainNameLabel
if !strings.EqualFold(to.String(existingDNSLabel), domainNameLabel) {
return false, fmt.Errorf("ensurePublicIPExists for service(%s): pip(%s) - there is an existing DNS label %s on the public IP", serviceName, pipName, *existingDNSLabel)
pip.PublicIPAddressPropertiesFormat.DNSSettings.DomainNameLabel = &domainNameLabel
changed = true
}
}

Expand Down
28 changes: 28 additions & 0 deletions pkg/provider/azure_loadbalancer_test.go
Expand Up @@ -4192,6 +4192,34 @@ func TestEnsurePublicIPExists(t *testing.T) {
},
shouldPutPIP: true,
},
{
desc: "shall update existed PIP's dns label for IPv6",
inputDNSLabel: "newdns",
foundDNSLabelAnnotation: true,
isIPv6: true,
existingPIPs: []network.PublicIPAddress{{

Name: to.StringPtr("pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr("previousdns"),
},
},
}},
expectedPIP: &network.PublicIPAddress{
Name: to.StringPtr("pip1"),
ID: to.StringPtr("/subscriptions/subscription/resourceGroups/rg" +
"/providers/Microsoft.Network/publicIPAddresses/pip1"),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
DNSSettings: &network.PublicIPAddressDNSSettings{
DomainNameLabel: to.StringPtr("newdns"),
},
PublicIPAllocationMethod: "Dynamic",
PublicIPAddressVersion: "IPv6",
},
},
shouldPutPIP: true,
},
{
desc: "shall report an conflict error if the DNS label is conflicted",
inputDNSLabel: "test",
Expand Down

0 comments on commit 4354fec

Please sign in to comment.