Skip to content

Commit cc869c8

Browse files
Merge pull request #2433 from pablintino/mco-irreconcilable-changes-api-change
MCO-1744: Add knobs to allow irreconcilable changes
2 parents c974eea + 5fd3adf commit cc869c8

File tree

30 files changed

+12222
-8
lines changed

30 files changed

+12222
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[TechPreview] IrreconcilableMachineConfig"
3+
crdName: machineconfignodes.machineconfiguration.openshift.io
4+
featureGates:
5+
- MachineConfigNodes
6+
- IrreconcilableMachineConfig
7+
tests:
8+
onUpdate:
9+
- name: Should be able to update a MachineConfigNode with a minimal irreconcilableChanges status field.
10+
initial: |
11+
apiVersion: machineconfiguration.openshift.io/v1
12+
kind: MachineConfigNode
13+
metadata:
14+
name: foobar
15+
spec:
16+
node:
17+
name: foobar
18+
pool:
19+
name: worker
20+
configVersion:
21+
desired: rendered-worker-abc
22+
updated: |
23+
apiVersion: machineconfiguration.openshift.io/v1
24+
kind: MachineConfigNode
25+
metadata:
26+
name: foobar
27+
spec:
28+
node:
29+
name: foobar
30+
pool:
31+
name: worker
32+
configVersion:
33+
desired: rendered-worker-abc
34+
status:
35+
irreconcilableChanges:
36+
- fieldPath: spec.config.storage.disks[0]
37+
diff: "dif content"
38+
expected: |
39+
apiVersion: machineconfiguration.openshift.io/v1
40+
kind: MachineConfigNode
41+
metadata:
42+
name: foobar
43+
spec:
44+
node:
45+
name: foobar
46+
pool:
47+
name: worker
48+
configVersion:
49+
desired: rendered-worker-abc
50+
status:
51+
irreconcilableChanges:
52+
- fieldPath: spec.config.storage.disks[0]
53+
diff: "dif content"
54+
- name: Should be able to update a MachineConfigNode to remove the irreconcilableChanges status field.
55+
initial: |
56+
apiVersion: machineconfiguration.openshift.io/v1
57+
kind: MachineConfigNode
58+
metadata:
59+
name: foobar
60+
spec:
61+
node:
62+
name: foobar
63+
pool:
64+
name: worker
65+
configVersion:
66+
desired: rendered-worker-abc
67+
status:
68+
irreconcilableChanges:
69+
- fieldPath: spec.config.storage.disks[0]
70+
diff: "dif content"
71+
updated: |
72+
apiVersion: machineconfiguration.openshift.io/v1
73+
kind: MachineConfigNode
74+
metadata:
75+
name: foobar
76+
spec:
77+
node:
78+
name: foobar
79+
pool:
80+
name: worker
81+
configVersion:
82+
desired: rendered-worker-abc
83+
status: {}
84+
expected: |
85+
apiVersion: machineconfiguration.openshift.io/v1
86+
kind: MachineConfigNode
87+
metadata:
88+
name: foobar
89+
spec:
90+
node:
91+
name: foobar
92+
pool:
93+
name: worker
94+
configVersion:
95+
desired: rendered-worker-abc
96+
status: {}
97+
98+
- name: Should not be able to set a fieldPath that does not start with spec. prefix in the irreconcilableChanges status field.
99+
initial: |
100+
apiVersion: machineconfiguration.openshift.io/v1
101+
kind: MachineConfigNode
102+
metadata:
103+
name: foobar
104+
spec:
105+
node:
106+
name: foobar
107+
pool:
108+
name: worker
109+
configVersion:
110+
desired: rendered-worker-abc
111+
status:
112+
irreconcilableChanges:
113+
- fieldPath: spec.config.storage.disks[0]
114+
diff: "dif content"
115+
updated: |
116+
apiVersion: machineconfiguration.openshift.io/v1
117+
kind: MachineConfigNode
118+
metadata:
119+
name: foobar
120+
spec:
121+
node:
122+
name: foobar
123+
pool:
124+
name: worker
125+
configVersion:
126+
desired: rendered-worker-abc
127+
status:
128+
irreconcilableChanges:
129+
- fieldPath: spec.config.storage.disks[0]
130+
diff: "dif content"
131+
- fieldPath: an.invalid.path
132+
diff: "dif content"
133+
expectedStatusError: "status.irreconcilableChanges[1].fieldPath: Invalid value: \"string\": The fieldPath must start with `spec.`"
134+
135+
- name: Should not be able to set a fieldPath with invalid characters in the irreconcilableChanges status field.
136+
initial: |
137+
apiVersion: machineconfiguration.openshift.io/v1
138+
kind: MachineConfigNode
139+
metadata:
140+
name: foobar
141+
spec:
142+
node:
143+
name: foobar
144+
pool:
145+
name: worker
146+
configVersion:
147+
desired: rendered-worker-abc
148+
status:
149+
irreconcilableChanges:
150+
- fieldPath: spec.config.storage.disks[0]
151+
diff: "dif content"
152+
updated: |
153+
apiVersion: machineconfiguration.openshift.io/v1
154+
kind: MachineConfigNode
155+
metadata:
156+
name: foobar
157+
spec:
158+
node:
159+
name: foobar
160+
pool:
161+
name: worker
162+
configVersion:
163+
desired: rendered-worker-abc
164+
status:
165+
irreconcilableChanges:
166+
- fieldPath: spec.config.storage.disks[0]
167+
diff: "dif content"
168+
- fieldPath: spec.config@field{1}
169+
diff: "dif content"
170+
expectedStatusError: "status.irreconcilableChanges[1].fieldPath: Invalid value: \"string\": The fieldPath must consist only of alphanumeric characters, brackets [] and dots ('.')."
171+
172+
- name: Should not be able to set set multiple diff elements for the same path in the irreconcilableChanges status field.
173+
initial: |
174+
apiVersion: machineconfiguration.openshift.io/v1
175+
kind: MachineConfigNode
176+
metadata:
177+
name: foobar
178+
spec:
179+
node:
180+
name: foobar
181+
pool:
182+
name: worker
183+
configVersion:
184+
desired: rendered-worker-abc
185+
status:
186+
irreconcilableChanges:
187+
- fieldPath: spec.config.storage.disks[0]
188+
diff: "dif content"
189+
updated: |
190+
apiVersion: machineconfiguration.openshift.io/v1
191+
kind: MachineConfigNode
192+
metadata:
193+
name: foobar
194+
spec:
195+
node:
196+
name: foobar
197+
pool:
198+
name: worker
199+
configVersion:
200+
desired: rendered-worker-abc
201+
status:
202+
irreconcilableChanges:
203+
- fieldPath: spec.config.storage.disks[0]
204+
diff: "dif content"
205+
- fieldPath: spec.config.storage.disks[0]
206+
diff: "dif content updated"
207+
expectedStatusError: "status.irreconcilableChanges[1]: Duplicate value: map[string]interface {}{\"fieldPath\":\"spec.config.storage.disks[0]\"}"

machineconfiguration/v1/types_machineconfignode.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,41 @@ type MachineConfigNodeStatus struct {
126126
// +kubebuilder:validation:MaxItems=100
127127
// +optional
128128
PinnedImageSets []MachineConfigNodeStatusPinnedImageSet `json:"pinnedImageSets,omitempty"`
129+
// irreconcilableChanges is an optional field that contains the observed differences between this nodes
130+
// configuration and the target rendered MachineConfig.
131+
// This field will be set when there are changes to the target rendered MachineConfig that can only be applied to
132+
// new nodes joining the cluster.
133+
// Entries must be unique, keyed on the fieldPath field.
134+
// Must not exceed 32 entries.
135+
// +listType=map
136+
// +listMapKey=fieldPath
137+
// +openshift:enable:FeatureGate=IrreconcilableMachineConfig
138+
// +kubebuilder:validation:MinItems=1
139+
// +kubebuilder:validation:MaxItems=32
140+
// +optional
141+
IrreconcilableChanges []IrreconcilableChangeDiff `json:"irreconcilableChanges,omitempty"`
142+
}
143+
144+
// IrreconcilableChangeDiff holds an individual diff between the initial install-time MachineConfig
145+
// and the latest applied one caused by the presence of irreconcilable changes.
146+
type IrreconcilableChangeDiff struct {
147+
// fieldPath is a required reference to the path in the latest rendered MachineConfig that differs from this nodes
148+
// configuration.
149+
// Must not be empty and must not exceed 70 characters in length.
150+
// Must begin with the prefix 'spec.' and only contain alphanumeric characters, square brackets ('[]'), or dots ('.').
151+
// +required
152+
// +kubebuilder:validation:MinLength=1
153+
// +kubebuilder:validation:MaxLength=70
154+
// +kubebuilder:validation:XValidation:rule="self.startsWith('spec.')",message="The fieldPath must start with `spec.`"
155+
// +kubebuilder:validation:XValidation:rule=`self.matches('^[\\da-zA-Z\\.\\[\\]]+$')`,message="The fieldPath must consist only of alphanumeric characters, brackets [] and dots ('.')."
156+
FieldPath string `json:"fieldPath,omitempty"`
157+
// diff is a required field containing the difference between the nodes current configuration and the latest
158+
// rendered MachineConfig for the field specified in fieldPath.
159+
// Must not be an empty string and must not exceed 4096 characters in length.
160+
// +required
161+
// +kubebuilder:validation:MinLength=1
162+
// +kubebuilder:validation:MaxLength=4096
163+
Diff string `json:"diff,omitempty"`
129164
}
130165

131166
// MachineConfigNodeStatusPinnedImageSet holds information about the current, desired, and failed pinned image sets for the observed machine config node.

0 commit comments

Comments
 (0)