Skip to content

Commit 8eeec92

Browse files
committed
Revert "Add LocalDNS State field and validation tests"
This reverts commit e5bd206.
1 parent 2836a91 commit 8eeec92

File tree

9 files changed

+30
-266
lines changed

9 files changed

+30
-266
lines changed

charts/karpenter-crd/templates/karpenter.azure.com_aksnodeclasses.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -726,18 +726,6 @@ spec:
726726
- Required
727727
- Disabled
728728
type: string
729-
state:
730-
allOf:
731-
- enum:
732-
- Enabled
733-
- Disabled
734-
- enum:
735-
- Enabled
736-
- Disabled
737-
description: |-
738-
State is the system-generated state of localDNS.
739-
This field is read-only and managed by the system.
740-
type: string
741729
vnetDNSOverrides:
742730
additionalProperties:
743731
description: LocalDNSOverrides specifies DNS override configuration
@@ -799,9 +787,6 @@ spec:
799787
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
800788
type: object
801789
type: object
802-
x-kubernetes-validations:
803-
- message: state is a read-only field and cannot be set by users
804-
rule: '!has(self.state)'
805790
maxPods:
806791
description: |-
807792
MaxPods is an override for the maximum number of pods that can run on a worker node instance.

pkg/apis/crds/karpenter.azure.com_aksnodeclasses.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -726,18 +726,6 @@ spec:
726726
- Required
727727
- Disabled
728728
type: string
729-
state:
730-
allOf:
731-
- enum:
732-
- Enabled
733-
- Disabled
734-
- enum:
735-
- Enabled
736-
- Disabled
737-
description: |-
738-
State is the system-generated state of localDNS.
739-
This field is read-only and managed by the system.
740-
type: string
741729
vnetDNSOverrides:
742730
additionalProperties:
743731
description: LocalDNSOverrides specifies DNS override configuration
@@ -799,9 +787,6 @@ spec:
799787
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
800788
type: object
801789
type: object
802-
x-kubernetes-validations:
803-
- message: state is a read-only field and cannot be set by users
804-
rule: '!has(self.state)'
805790
maxPods:
806791
description: |-
807792
MaxPods is an override for the maximum number of pods that can run on a worker node instance.

pkg/apis/v1beta1/aksnodeclass.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,10 @@ const (
117117
// LocalDNS configures the per-node local DNS, with VnetDNS and KubeDNS overrides.
118118
// LocalDNS helps improve performance and reliability of DNS resolution in an AKS cluster.
119119
// For more details see aka.ms/aks/localdns.
120-
// +kubebuilder:validation:XValidation:rule="!has(self.state)",message="state is a read-only field and cannot be set by users"
121120
type LocalDNS struct {
122121
// Mode of enablement for localDNS.
123122
// +optional
124123
Mode *LocalDNSMode `json:"mode,omitempty"`
125-
126-
// State is the system-generated state of localDNS.
127-
// This field is read-only and managed by the system.
128-
// +optional
129-
// +kubebuilder:validation:Enum:={Enabled,Disabled}
130-
State *LocalDNSState `json:"state,omitempty"`
131-
132124
// VnetDNS overrides apply to DNS traffic from pods with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
133125
// +optional
134126
VnetDNSOverrides map[string]*LocalDNSOverrides `json:"vnetDNSOverrides,omitempty"`
@@ -137,16 +129,6 @@ type LocalDNS struct {
137129
KubeDNSOverrides map[string]*LocalDNSOverrides `json:"kubeDNSOverrides,omitempty"`
138130
}
139131

140-
// +kubebuilder:validation:Enum:={Enabled,Disabled}
141-
type LocalDNSState string
142-
143-
const (
144-
// localDNS is enabled.
145-
LocalDNSStateEnabled LocalDNSState = "Enabled"
146-
// localDNS is disabled.
147-
LocalDNSStateDisabled LocalDNSState = "Disabled"
148-
)
149-
150132
// LocalDNSOverrides specifies DNS override configuration
151133
type LocalDNSOverrides struct {
152134
// Log level for DNS queries in localDNS.

pkg/apis/v1beta1/crd_validation_cel_test.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -446,63 +446,6 @@ var _ = Describe("CEL/Validation", func() {
446446
GinkgoWriter.Printf("Error for 'Never' serveStaleDuration: %s\n", err.Error())
447447
Expect(err.Error()).To(ContainSubstring("\"Never\": spec.localDNS.vnetDNSOverrides.test.domain.serveStaleDuration in body should match '^([0-9]+(s|m|h))+$'"))
448448
})
449-
450-
It("should reject State field when set by users on create", func() {
451-
// Test that users cannot set the state field
452-
nodeClass := &v1beta1.AKSNodeClass{
453-
ObjectMeta: metav1.ObjectMeta{Name: strings.ToLower(randomdata.SillyName())},
454-
Spec: v1beta1.AKSNodeClassSpec{
455-
LocalDNS: &v1beta1.LocalDNS{
456-
Mode: lo.ToPtr(v1beta1.LocalDNSModeRequired),
457-
State: lo.ToPtr(v1beta1.LocalDNSStateEnabled), // User trying to set state
458-
},
459-
},
460-
}
461-
err := env.Client.Create(ctx, nodeClass)
462-
Expect(err).To(HaveOccurred())
463-
GinkgoWriter.Printf("Error when user sets state on create: %s\n", err.Error())
464-
Expect(err.Error()).To(ContainSubstring("state is a read-only field and cannot be set by users"))
465-
})
466-
467-
It("should reject State field when set by users on patch", func() {
468-
// Create a valid nodeClass without state
469-
nodeClass := &v1beta1.AKSNodeClass{
470-
ObjectMeta: metav1.ObjectMeta{Name: strings.ToLower(randomdata.SillyName())},
471-
Spec: v1beta1.AKSNodeClassSpec{
472-
LocalDNS: &v1beta1.LocalDNS{
473-
Mode: lo.ToPtr(v1beta1.LocalDNSModeRequired),
474-
},
475-
},
476-
}
477-
Expect(env.Client.Create(ctx, nodeClass)).To(Succeed())
478-
479-
// Try to patch with state field using raw JSON
480-
patch := []byte(`{"spec":{"localDNS":{"state":"Enabled"}}}`)
481-
err := env.Client.Patch(ctx, nodeClass, client.RawPatch(client.Merge.Type(), patch))
482-
Expect(err).To(HaveOccurred())
483-
GinkgoWriter.Printf("Error when user patches state: %s\n", err.Error())
484-
Expect(err.Error()).To(ContainSubstring("state is a read-only field and cannot be set by users"))
485-
})
486-
487-
It("should reject State field when set by users on update", func() {
488-
// Create a valid nodeClass without state
489-
nodeClass := &v1beta1.AKSNodeClass{
490-
ObjectMeta: metav1.ObjectMeta{Name: strings.ToLower(randomdata.SillyName())},
491-
Spec: v1beta1.AKSNodeClassSpec{
492-
LocalDNS: &v1beta1.LocalDNS{
493-
Mode: lo.ToPtr(v1beta1.LocalDNSModeRequired),
494-
},
495-
},
496-
}
497-
Expect(env.Client.Create(ctx, nodeClass)).To(Succeed())
498-
499-
// Try to update with state field
500-
nodeClass.Spec.LocalDNS.State = lo.ToPtr(v1beta1.LocalDNSStateEnabled)
501-
err := env.Client.Update(ctx, nodeClass)
502-
Expect(err).To(HaveOccurred())
503-
GinkgoWriter.Printf("Error when user updates with state: %s\n", err.Error())
504-
Expect(err.Error()).To(ContainSubstring("state is a read-only field and cannot be set by users"))
505-
})
506449
})
507450

508451
Context("OSDiskSizeGB", func() {

pkg/apis/v1beta1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/providers/imagefamily/customscriptsbootstrap/provisionclientbootstrap.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,6 @@ func (p ProvisionClientBootstrap) GetCustomDataAndCSE(ctx context.Context) (stri
7979
if p.NodeBootstrappingProvider == nil {
8080
return "", "", fmt.Errorf("nodeBootstrapping provider is not initialized")
8181
}
82-
83-
// TODO: Delete: Set state field if LocalDNS is configured
84-
if p.LocalDNSProfile != nil {
85-
mode := v1beta1.LocalDNSModePreferred
86-
if p.LocalDNSProfile.Mode != nil {
87-
mode = *p.LocalDNSProfile.Mode
88-
}
89-
if mode == v1beta1.LocalDNSModeDisabled {
90-
p.LocalDNSProfile.State = lo.ToPtr(v1beta1.LocalDNSStateDisabled)
91-
} else {
92-
p.LocalDNSProfile.State = lo.ToPtr(v1beta1.LocalDNSStateEnabled)
93-
}
94-
}
95-
9682
nodeBootstrapping, err := p.NodeBootstrappingProvider.Get(ctx, provisionValues)
9783
if err != nil {
9884
// As of now we just fail the provisioning given the unlikely scenario of retriable error, but could be revisited along with retriable status on the server side.

pkg/provisionclients/models/local_dns_profile.go

Lines changed: 0 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/provisionclients/swagger/nodebootstrapping.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -324,28 +324,6 @@
324324
"description": "Mode of enablement for localDNS.",
325325
"default": "Preferred"
326326
},
327-
"state": {
328-
"type": "string",
329-
"enum": [
330-
"Enabled",
331-
"Disabled"
332-
],
333-
"x-ms-enum": {
334-
"name": "LocalDNSState",
335-
"modelAsString": true,
336-
"values": [
337-
{
338-
"value": "Enabled",
339-
"description": "localDNS is enabled."
340-
},
341-
{
342-
"value": "Disabled",
343-
"description": "localDNS is disabled."
344-
}
345-
]
346-
},
347-
"description": "System-generated state of localDNS."
348-
},
349327
"vnetDNSOverrides": {
350328
"type": "object",
351329
"description": "VnetDNS overrides apply to DNS traffic from pods with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).",

0 commit comments

Comments
 (0)