Skip to content

Commit e321599

Browse files
authored
Merge pull request #4368 from k8s-infra-cherrypick-robot/cherry-pick-4308-to-release-1.12
[release-1.12] Fix: DNSPrefix error on existing tenant cluster
2 parents e724050 + f4d089f commit e321599

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

api/v1beta1/azuremanagedcontrolplane_default.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1beta1
1919
import (
2020
"encoding/base64"
2121
"fmt"
22+
"reflect"
2223
"strings"
2324

2425
"golang.org/x/crypto/ssh"
@@ -194,7 +195,7 @@ func (m *AzureManagedControlPlane) setDefaultOIDCIssuerProfile() {
194195
}
195196

196197
func (m *AzureManagedControlPlane) setDefaultDNSPrefix() {
197-
if m.Spec.DNSPrefix == nil {
198+
if reflect.ValueOf(m.Spec.DNSPrefix).IsZero() {
198199
m.Spec.DNSPrefix = ptr.To(m.Name)
199200
}
200201
}

api/v1beta1/azuremanagedcontrolplane_webhook.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,20 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o
207207
allErrs = append(allErrs, err)
208208
}
209209

210+
oldDNSPrefix := old.Spec.DNSPrefix
211+
newDNSPrefix := m.Spec.DNSPrefix
212+
if reflect.ValueOf(oldDNSPrefix).IsZero() {
213+
oldDNSPrefix = ptr.To(old.Name)
214+
}
215+
216+
if reflect.ValueOf(newDNSPrefix).IsZero() {
217+
newDNSPrefix = ptr.To(m.Name)
218+
}
219+
210220
if err := webhookutils.ValidateImmutable(
211221
field.NewPath("Spec", "DNSPrefix"),
212-
m.Spec.DNSPrefix,
213-
old.Spec.DNSPrefix,
222+
oldDNSPrefix,
223+
newDNSPrefix,
214224
); err != nil {
215225
allErrs = append(allErrs, err)
216226
}

0 commit comments

Comments
 (0)