From d82721b2694d360ca677468a8b2f03d877be40a4 Mon Sep 17 00:00:00 2001 From: Nader Ziada Date: Wed, 30 Sep 2020 13:25:37 -0400 Subject: [PATCH] don't set the DNS record for the outbound public ip - only ip needed by azure - exisitng clusters will get their dns removed, but not an issue - keep ip name simple --- cloud/services/publicips/publicips.go | 14 ++++++++++---- cloud/services/publicips/publicips_test.go | 7 ++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cloud/services/publicips/publicips.go b/cloud/services/publicips/publicips.go index 33406277db0..2b4242d9ac1 100644 --- a/cloud/services/publicips/publicips.go +++ b/cloud/services/publicips/publicips.go @@ -31,11 +31,20 @@ func (s *Service) Reconcile(ctx context.Context) error { for _, ip := range s.Scope.PublicIPSpecs() { s.Scope.V(2).Info("creating public IP", "public ip", ip.Name) + // only set DNS properties if there is a DNS name specified addressVersion := network.IPv4 if ip.IsIPv6 { addressVersion = network.IPv6 } + var dnsSettings *network.PublicIPAddressDNSSettings + if ip.DNSName != "" { + dnsSettings = &network.PublicIPAddressDNSSettings{ + DomainNameLabel: to.StringPtr(strings.ToLower(ip.Name)), + Fqdn: to.StringPtr(ip.DNSName), + } + } + err := s.Client.CreateOrUpdate( ctx, s.Scope.ResourceGroup(), @@ -47,10 +56,7 @@ func (s *Service) Reconcile(ctx context.Context) error { PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{ PublicIPAddressVersion: addressVersion, PublicIPAllocationMethod: network.Static, - DNSSettings: &network.PublicIPAddressDNSSettings{ - DomainNameLabel: to.StringPtr(strings.ToLower(ip.Name)), - Fqdn: to.StringPtr(ip.DNSName), - }, + DNSSettings: dnsSettings, }, }, ) diff --git a/cloud/services/publicips/publicips_test.go b/cloud/services/publicips/publicips_test.go index f8b8c3365ba..c933e3a1007 100644 --- a/cloud/services/publicips/publicips_test.go +++ b/cloud/services/publicips/publicips_test.go @@ -19,9 +19,10 @@ package publicips import ( "context" "net/http" - gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" "testing" + gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" + azure "sigs.k8s.io/cluster-api-provider-azure/cloud" . "github.com/onsi/gomega" @@ -106,10 +107,6 @@ func TestReconcilePublicIP(t *testing.T) { PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{ PublicIPAddressVersion: network.IPv4, PublicIPAllocationMethod: network.Static, - DNSSettings: &network.PublicIPAddressDNSSettings{ - DomainNameLabel: to.StringPtr("my-publicip-3"), - Fqdn: to.StringPtr(""), - }, }, })).Times(1), m.CreateOrUpdate(context.TODO(), "my-rg", "my-publicip-ipv6", gomockinternal.DiffEq(network.PublicIPAddress{