Skip to content

Commit 709f275

Browse files
default to public Azure instance in DNSRecord actuator (#938)
1 parent 382ee12 commit 709f275

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

pkg/controller/dnsrecord/actuator.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"time"
1111

12+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
1213
extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
1314
"github.com/gardener/gardener/extensions/pkg/controller/dnsrecord"
1415
"github.com/gardener/gardener/extensions/pkg/util"
@@ -52,9 +53,16 @@ func (a *actuator) Reconcile(ctx context.Context, log logr.Logger, dns *extensio
5253
return err
5354
}
5455

55-
azCloudConfiguration, err := azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region)
56-
if err != nil {
57-
return err
56+
var azCloudConfiguration cloud.Configuration
57+
// Unlike for the other actuators, both of the values used to determine the cloud instance might be nil - usually the region would not be.
58+
// Default to the public cloud in this case.
59+
if dnsRecordConfig.CloudConfiguration != nil || dns.Spec.Region != nil {
60+
azCloudConfiguration, err = azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region)
61+
if err != nil {
62+
return err
63+
}
64+
} else {
65+
azCloudConfiguration = cloud.AzurePublic
5866
}
5967

6068
clientFactory, err := DefaultAzureClientFactoryFunc(
@@ -106,10 +114,16 @@ func (a *actuator) Delete(ctx context.Context, log logr.Logger, dns *extensionsv
106114
return err
107115
}
108116

109-
azCloudConfiguration, err := azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region)
110-
111-
if err != nil {
112-
return err
117+
var azCloudConfiguration cloud.Configuration
118+
// Unlike for the other actuators, both of the values used to determine the cloud instance might be nil - usually the region would not be.
119+
// Default to the public cloud in this case.
120+
if dnsRecordConfig.CloudConfiguration != nil || dns.Spec.Region != nil {
121+
azCloudConfiguration, err = azureclient.AzureCloudConfiguration(dnsRecordConfig.CloudConfiguration, dns.Spec.Region)
122+
if err != nil {
123+
return err
124+
}
125+
} else {
126+
azCloudConfiguration = cloud.AzurePublic
113127
}
114128

115129
clientFactory, err := DefaultAzureClientFactoryFunc(

0 commit comments

Comments
 (0)