Skip to content

Commit 2f4b91e

Browse files
Merge pull request #2442 from isabella-janssen/mco-1675-rebase
MCO-1675: Update API for Status Reporting needs (REBASED)
2 parents 9116741 + daaca27 commit 2f4b91e

16 files changed

+1195
-1
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[FeatureGate] ImageModeStatusReporting"
3+
crdName: machineconfignodes.machineconfiguration.openshift.io
4+
featureGates:
5+
- ImageModeStatusReporting
6+
tests:
7+
onCreate:
8+
- name: Should be able to create MachineConfigNode when spec.configImage ImageModeStatusReporting is enabled
9+
initial: |
10+
apiVersion: machineconfiguration.openshift.io/v1
11+
kind: MachineConfigNode
12+
metadata:
13+
name: test-imagemodestatusreporting
14+
spec:
15+
node:
16+
name: test-imagemodestatusreporting
17+
pool:
18+
name: worker
19+
configVersion:
20+
desired: rendered-worker-abc
21+
configImage:
22+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
23+
expected: |
24+
apiVersion: machineconfiguration.openshift.io/v1
25+
kind: MachineConfigNode
26+
metadata:
27+
name: test-imagemodestatusreporting
28+
spec:
29+
node:
30+
name: test-imagemodestatusreporting
31+
pool:
32+
name: worker
33+
configVersion:
34+
desired: rendered-worker-abc
35+
configImage:
36+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
37+
- name: spec.configImage.desiredImage should enforce MaxLength.
38+
initial: |
39+
apiVersion: machineconfiguration.openshift.io/v1
40+
kind: MachineConfigNode
41+
metadata:
42+
name: test-imagemodestatusreporting
43+
spec:
44+
node:
45+
name: test-imagemodestatusreporting
46+
pool:
47+
name: worker
48+
configVersion:
49+
desired: rendered-worker-abc
50+
configImage:
51+
desiredImage: registry.example.com/a/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very//very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/very/j
52+
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
53+
- name: Should not be able to create a MachineConfigNode with desiredImage set to a tag-based image reference
54+
initial: |
55+
apiVersion: machineconfiguration.openshift.io/v1
56+
kind: MachineConfigNode
57+
metadata:
58+
name: test-imagemodestatusreporting
59+
spec:
60+
node:
61+
name: test-imagemodestatusreporting
62+
pool:
63+
name: worker
64+
configVersion:
65+
desired: rendered-worker-abc
66+
configImage:
67+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/os-images:latest
68+
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
69+
- name: spec.configImage.desiredImage should enforce 256 image digest format.
70+
initial: |
71+
apiVersion: machineconfiguration.openshift.io/v1
72+
kind: MachineConfigNode
73+
metadata:
74+
name: test-imagemodestatusreporting
75+
spec:
76+
node:
77+
name: test-imagemodestatusreporting
78+
pool:
79+
name: worker
80+
configVersion:
81+
desired: rendered-worker-abc
82+
configImage:
83+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/os-images@sha512:a2c24b2903ad327e06bf57ac1d34e4e99e284309ccc69a5ffcc640121c0f82a05a841e915edb1b633ca52692bd019e1fcdd09d3f0730ace8f49c96b3bd020216
84+
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
85+
onUpdate:
86+
- name: Should be able to create MachineConfigNode with status.configImage when ImageModeStatusReporting is enabled when the current and desired images are the same
87+
initial: |
88+
apiVersion: machineconfiguration.openshift.io/v1
89+
kind: MachineConfigNode
90+
metadata:
91+
name: test-imagemodestatusreporting
92+
spec:
93+
node:
94+
name: test-imagemodestatusreporting
95+
pool:
96+
name: worker
97+
configVersion:
98+
desired: rendered-worker-abc
99+
configImage:
100+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
101+
updated: |
102+
apiVersion: machineconfiguration.openshift.io/v1
103+
kind: MachineConfigNode
104+
metadata:
105+
name: test-imagemodestatusreporting
106+
spec:
107+
node:
108+
name: test-imagemodestatusreporting
109+
pool:
110+
name: worker
111+
configVersion:
112+
desired: rendered-worker-abc
113+
configImage:
114+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
115+
status:
116+
configImage:
117+
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
118+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
119+
expected: |
120+
apiVersion: machineconfiguration.openshift.io/v1
121+
kind: MachineConfigNode
122+
metadata:
123+
name: test-imagemodestatusreporting
124+
spec:
125+
node:
126+
name: test-imagemodestatusreporting
127+
pool:
128+
name: worker
129+
configVersion:
130+
desired: rendered-worker-abc
131+
configImage:
132+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
133+
status:
134+
configImage:
135+
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
136+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
137+
- name: Should be able to create MachineConfigNode with status.configImage when ImageModeStatusReporting is enabled when the current and desired images are the different.
138+
initial: |
139+
apiVersion: machineconfiguration.openshift.io/v1
140+
kind: MachineConfigNode
141+
metadata:
142+
name: test-imagemodestatusreporting
143+
spec:
144+
node:
145+
name: test-imagemodestatusreporting
146+
pool:
147+
name: worker
148+
configVersion:
149+
desired: rendered-worker-abc
150+
configImage:
151+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
152+
updated: |
153+
apiVersion: machineconfiguration.openshift.io/v1
154+
kind: MachineConfigNode
155+
metadata:
156+
name: test-imagemodestatusreporting
157+
spec:
158+
node:
159+
name: test-imagemodestatusreporting
160+
pool:
161+
name: worker
162+
configVersion:
163+
desired: rendered-worker-abc
164+
configImage:
165+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
166+
status:
167+
configImage:
168+
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:c47856f56e1fdb7c9d10a1658e4ea85fbea44d71fb0e82898d152b47e0f894c6
169+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
170+
expected: |
171+
apiVersion: machineconfiguration.openshift.io/v1
172+
kind: MachineConfigNode
173+
metadata:
174+
name: test-imagemodestatusreporting
175+
spec:
176+
node:
177+
name: test-imagemodestatusreporting
178+
pool:
179+
name: worker
180+
configVersion:
181+
desired: rendered-worker-abc
182+
configImage:
183+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
184+
status:
185+
configImage:
186+
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:c47856f56e1fdb7c9d10a1658e4ea85fbea44d71fb0e82898d152b47e0f894c6
187+
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
188+

machineconfiguration/v1/types_machineconfignode.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ type MachineConfigNodeSpec struct {
9898
// the new machine config against the current machine config.
9999
// +required
100100
ConfigVersion MachineConfigNodeSpecMachineConfigVersion `json:"configVersion"`
101+
102+
// configImage is an optional field for configuring the OS image to be used for this node. This field will only exist if the node belongs to a pool opted into on-cluster image builds, and will override any MachineConfig referenced OSImageURL fields
103+
// When omitted, Image Mode is not be enabled and the node will follow the standard update process of creating a rendered MachineConfig and updating to its specifications.
104+
// When specified, Image Mode is enabled and will attempt to update the node to use the desired image. Following this, the node will follow the standard update process of creating a rendered MachineConfig and updating to its specifications.
105+
// +openshift:enable:FeatureGate=ImageModeStatusReporting
106+
// +optional
107+
ConfigImage MachineConfigNodeSpecConfigImage `json:"configImage,omitempty,omitzero"`
101108
}
102109

103110
// MachineConfigNodeStatus holds the reported information on a particular machine config node.
@@ -106,6 +113,8 @@ type MachineConfigNodeStatus struct {
106113
// UpdatePrepared, UpdateExecuted, UpdatePostActionComplete, UpdateComplete, Updated, Resumed,
107114
// Drained, AppliedFilesAndOS, Cordoned, Uncordoned, RebootedNode, NodeDegraded, PinnedImageSetsProgressing,
108115
// and PinnedImageSetsDegraded.
116+
// The following types are only available when the ImageModeStatusReporting feature gate is enabled: ImagePulledFromRegistry,
117+
// AppliedOSImage, AppliedFiles
109118
// +listType=map
110119
// +listMapKey=type
111120
// +kubebuilder:validation:MaxItems=20
@@ -120,6 +129,15 @@ type MachineConfigNodeStatus struct {
120129
// configVersion describes the current and desired machine config version for this node.
121130
// +optional
122131
ConfigVersion *MachineConfigNodeStatusMachineConfigVersion `json:"configVersion,omitempty"`
132+
// configImage is an optional field for configuring the OS image to be used for this node. This field will only exist if the node belongs to a pool opted into on-cluster image builds, and will override any MachineConfig referenced OSImageURL fields.
133+
// When omitted, this means that the Image Mode feature is not being used and the node will be up to date with the specific current rendered config version for the nodes MachinePool.
134+
// When specified, the Image Mode feature is enabled and the contents of this field show the observed state of the node image.
135+
// When Image Mode is enabled and a new MachineConfig is applied such that a new OS image build is not created, only the configVersion field will change.
136+
// When Image Mode is enabled and a new MachineConfig is applied such that a new OS image build is created, then only the configImage field will change. It is also possible that both the configImage
137+
// and configVersion change during the same update.
138+
// +openshift:enable:FeatureGate=ImageModeStatusReporting
139+
// +optional
140+
ConfigImage MachineConfigNodeStatusConfigImage `json:"configImage,omitempty,omitzero"`
123141
// pinnedImageSets describes the current and desired pinned image sets for this node.
124142
// +listType=map
125143
// +listMapKey=name
@@ -244,6 +262,41 @@ type MachineConfigNodeSpecMachineConfigVersion struct {
244262
Desired string `json:"desired"`
245263
}
246264

265+
// MachineConfigNodeSpecConfigImage holds the desired image for the node.
266+
// This structure is populated from the `machineconfiguration.openshift.io/desiredImage`
267+
// annotation on the target node, which is set by the Machine Config Pool controller
268+
// to signal the desired image pullspec for the node to update to.
269+
type MachineConfigNodeSpecConfigImage struct {
270+
// desiredImage is a required field that configures the image that the node should be updated to use.
271+
// It must be a fully qualified OCI image pull spec of the format host[:port][/namespace]/name@sha256:, where the digest must be exactly 64 characters in length and consist only of lowercase hexadecimal characters, a-f and 0-9.
272+
// desiredImage must not be an empty string and must not exceed 447 characters in length.
273+
// +required
274+
DesiredImage ImageDigestFormat `json:"desiredImage,omitempty"`
275+
}
276+
277+
// MachineConfigNodeStatusConfigImage holds the observed state of the image
278+
// on the node, including both the image targeted for an update and the image
279+
// currently applied. This allows for monitoring the progress of the layering
280+
// rollout. If Image Mode is enabled, desiredImage must be defined.
281+
// +kubebuilder:validation:MinProperties:=1
282+
type MachineConfigNodeStatusConfigImage struct {
283+
// currentImage is an optional field that represents the current image that is applied to the node.
284+
// When omitted, this means that no image updates have been applied to the node and it will be up to date with the specific current rendered config version.
285+
// When specified, this means that the node is currently using this image.
286+
// currentImage must be a fully qualified OCI image pull spec of the format host[:port][/namespace]/name@sha256:, where the digest must be exactly 64 characters in length and consist only of lowercase hexadecimal characters, a-f and 0-9.
287+
// currentImage must not be an empty string and must not exceed 447 characters in length.
288+
// +optional
289+
CurrentImage ImageDigestFormat `json:"currentImage,omitzero,omitempty"`
290+
// desiredImage is an optional field that represents the currently observed state of image that the node should be updated to use.
291+
// When not specified, this means that Image Mode has been disabled and the node will up to date with the specific current rendered config version.
292+
// When specified, this means that Image Mode has been enabled and the node is actively progressing to update the node to this image.
293+
// If currentImage and desiredImage match, the node has been successfully updated to use the desired image.
294+
// desiredImage must be a fully qualified OCI image pull spec of the format host[:port][/namespace]/name@sha256:, where the digest must be exactly 64 characters in length and consist only of lowercase hexadecimal characters, a-f and 0-9.
295+
// desiredImage must not be an empty string and must not exceed 447 characters in length.
296+
// +optional
297+
DesiredImage ImageDigestFormat `json:"desiredImage,omitzero,omitempty"`
298+
}
299+
247300
// StateProgress is each possible state for each possible MachineConfigNodeType
248301
// +enum
249302
type StateProgress string
@@ -263,8 +316,14 @@ const (
263316
MachineConfigNodeResumed StateProgress = "Resumed"
264317
// MachineConfigNodeUpdateDrained describes the part of the in progress phase where the node drains
265318
MachineConfigNodeUpdateDrained StateProgress = "Drained"
319+
// MachineConfigNodeUpdateFiles describes the part of the in progress phase where the nodes files changes
320+
MachineConfigNodeUpdateFiles StateProgress = "AppliedFiles"
321+
// MachineConfigNodeUpdateOS describes the part of the in progress phase where the OS config changes
322+
MachineConfigNodeUpdateOS StateProgress = "AppliedOSImage"
266323
// MachineConfigNodeUpdateFilesAndOS describes the part of the in progress phase where the nodes files and OS config change
267324
MachineConfigNodeUpdateFilesAndOS StateProgress = "AppliedFilesAndOS"
325+
// MachineConfigNodeImagePulledFromRegistry describes the part of the in progress phase where the update image is pulled from the registry
326+
MachineConfigNodeImagePulledFromRegistry StateProgress = "ImagePulledFromRegistry"
268327
// MachineConfigNodeUpdateCordoned describes the part of the in progress phase where the node cordons
269328
MachineConfigNodeUpdateCordoned StateProgress = "Cordoned"
270329
// MachineConfigNodeUpdateUncordoned describes the part of the completing phase where the node uncordons

0 commit comments

Comments
 (0)