Skip to content

Commit 999c45c

Browse files
Merge pull request #2510 from andfasano/add-internalreleaseimage-resource
AGENT-1330: machineconfiguration/v1alpha1: add InternalReleaseImage
2 parents 88cca31 + 7a0d946 commit 999c45c

File tree

38 files changed

+8240
-8
lines changed

38 files changed

+8240
-8
lines changed

hack/update-payload-crds.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ crd_globs="\
2424
config/v1/zz_generated.crd-manifests/0000_10_openshift-controller-manager_01_builds*.crd.yaml
2525
operator/v1/zz_generated.crd-manifests/0000_50_openshift-controller-manager_02_openshiftcontrollermanagers*.crd.yaml
2626
machineconfiguration/v1/zz_generated.crd-manifests/*.crd.yaml
27+
machineconfiguration/v1alpha1/zz_generated.crd-manifests/0000_80_machine-config_01_internalreleaseimages-*.crd.yaml
2728
operator/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfigurations*.crd.yaml
2829
config/v1alpha1/zz_generated.crd-manifests/0000_10_config-operator_01_clustermonitoring*.crd.yaml
2930
operator/v1/zz_generated.crd-manifests/*_storage_01_storages*.crd.yaml
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "[TechPreview] InternalReleaseImage"
3+
crdName: machineconfignodes.machineconfiguration.openshift.io
4+
featureGates:
5+
- MachineConfigNodes
6+
- NoRegistryClusterInstall
7+
tests:
8+
onUpdate:
9+
- name: Should be able to update a MachineConfigNode with a minimal internalReleaseImage 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: master
20+
configVersion:
21+
desired: rendered-master-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: master
32+
configVersion:
33+
desired: rendered-master-abc
34+
status:
35+
internalReleaseImage:
36+
releases:
37+
- name: ocp-release-bundle-4.18.0-x86_64
38+
image: example.com/example/openshift-release-dev@sha256:d98795f7932441b30bb8bcfbbf05912875383fad1f2b3be08a22ec148d68607f
39+
conditions:
40+
- type: Mounted
41+
status: "False"
42+
reason: "Mounted"
43+
message: ""
44+
lastTransitionTime: "2024-12-01T08:04:21Z"
45+
- type: Available
46+
status: "True"
47+
reason: "Available"
48+
message: "Release ocp-release-bundle-4.18.0-x86_64 is currently available on node master-0"
49+
lastTransitionTime: "2024-12-01T08:04:21Z"
50+
- type: Degraded
51+
status: "False"
52+
reason: "Degraded"
53+
message: ""
54+
lastTransitionTime: "2024-12-01T08:04:21Z"
55+
expected: |
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: master
65+
configVersion:
66+
desired: rendered-master-abc
67+
status:
68+
internalReleaseImage:
69+
releases:
70+
- name: ocp-release-bundle-4.18.0-x86_64
71+
image: example.com/example/openshift-release-dev@sha256:d98795f7932441b30bb8bcfbbf05912875383fad1f2b3be08a22ec148d68607f
72+
conditions:
73+
- type: Mounted
74+
status: "False"
75+
reason: "Mounted"
76+
message: ""
77+
lastTransitionTime: "2024-12-01T08:04:21Z"
78+
- type: Available
79+
status: "True"
80+
reason: "Available"
81+
message: "Release ocp-release-bundle-4.18.0-x86_64 is currently available on node master-0"
82+
lastTransitionTime: "2024-12-01T08:04:21Z"
83+
- type: Degraded
84+
status: "False"
85+
reason: "Degraded"
86+
message: ""
87+
lastTransitionTime: "2024-12-01T08:04:21Z"

machineconfiguration/v1/types_machineconfignode.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,89 @@ type MachineConfigNodeStatus struct {
158158
// +kubebuilder:validation:MaxItems=32
159159
// +optional
160160
IrreconcilableChanges []IrreconcilableChangeDiff `json:"irreconcilableChanges,omitempty"`
161+
// internalReleaseImage describes the status of the release payloads stored in the node.
162+
// When specified, an internalReleaseImage custom resource exists on the cluster, and the specified images will be made available on the control plane nodes.
163+
// This field will reflect the actual on-disk state of those release images.
164+
// +openshift:enable:FeatureGate=NoRegistryClusterInstall
165+
// +optional
166+
InternalReleaseImage MachineConfigNodeStatusInternalReleaseImage `json:"internalReleaseImage,omitzero,omitempty"`
167+
}
168+
169+
// MachineConfigNodeStatusInternalReleaseImage holds information about the current and discovered release bundles for the observed machine
170+
// config node.
171+
type MachineConfigNodeStatusInternalReleaseImage struct {
172+
// releases is a list of the release bundles currently owned and managed by the
173+
// cluster.
174+
// A release bundle content could be safely pulled only when its Conditions field
175+
// contains at least an Available entry set to "True" and Degraded to "False".
176+
// Entries must be unique, keyed on the name field.
177+
// releases must contain at least one entry and must not exceed 32 entries.
178+
// +listType=map
179+
// +listMapKey=name
180+
// +kubebuilder:validation:MinItems=1
181+
// +kubebuilder:validation:MaxItems=32
182+
// +required
183+
Releases []MachineConfigNodeStatusInternalReleaseImageRef `json:"releases,omitempty"`
184+
}
185+
186+
// MachineConfigNodeStatusInternalReleaseImageRef is used to provide a more detailed reference for
187+
// a release bundle.
188+
type MachineConfigNodeStatusInternalReleaseImageRef struct {
189+
// conditions represent the observations of an internal release image current state. Valid types are:
190+
// Mounted, Installing, Available, Removing and Degraded.
191+
//
192+
// If Mounted is true, that means that a valid ISO has been mounted on the current node.
193+
// If Installing is true, that means that a new release bundle is currently being copied on the current node, and not yet completed.
194+
// If Available is true, it means that the release has been previously installed on the current node, and it can be used.
195+
// If Removing is true, it means that a release deletion is in progress on the current node, and not yet completed.
196+
// If Degraded is true, that means something has gone wrong in the current node.
197+
//
198+
// +listType=map
199+
// +listMapKey=type
200+
// +kubebuilder:validation:MinItems=1
201+
// +kubebuilder:validation:MaxItems=5
202+
// +optional
203+
Conditions []metav1.Condition `json:"conditions,omitempty"`
204+
// name indicates the desired release bundle identifier. This field is required and must be between 1 and 64 characters long.
205+
// The expected name format is ocp-release-bundle-<version>-<arch|stream>.
206+
// +kubebuilder:validation:MinLength=1
207+
// +kubebuilder:validation:MaxLength=64
208+
// +kubebuilder:validation:XValidation:rule=`self.matches('^ocp-release-bundle-[0-9]+\\.[0-9]+\\.[0-9]+-[A-Za-z0-9._-]+$')`,message="must be ocp-release-bundle-<version>-<arch|stream> and <= 64 chars"
209+
// +required
210+
Name string `json:"name,omitempty"`
211+
// image is an OCP release image referenced by digest.
212+
// The format of the image pull spec is: host[:port][/namespace]/name@sha256:<digest>,
213+
// where the digest must be 64 characters long, and consist only of lowercase hexadecimal characters, a-f and 0-9.
214+
// The length of the whole spec must be between 1 to 447 characters.
215+
// The field is optional, and it will be provided after a release will be successfully installed.
216+
// +kubebuilder:validation:MinLength=1
217+
// +kubebuilder:validation:MaxLength=447
218+
// +kubebuilder:validation:XValidation:rule=`(self.split('@').size() == 2 && self.split('@')[1].matches('^sha256:[a-f0-9]{64}$'))`,message="the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
219+
// +kubebuilder:validation:XValidation:rule=`(self.split('@')[0].matches('^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+(:[0-9]{2,5})?/([a-zA-Z0-9-_]{0,61}/)?[a-zA-Z0-9-_.]*?$'))`,message="the OCI Image name should follow the host[:port][/namespace]/name format, resembling a valid URL without the scheme"
220+
// +optional
221+
Image string `json:"image,omitempty"`
161222
}
162223

224+
// InternalReleaseImageConditionType is each possible state for each possible InternalReleaseImageBundleStatus
225+
// conditions type.
226+
// +enum
227+
type InternalReleaseImageConditionType string
228+
229+
const (
230+
// InternalReleaseImageConditionTypeMounted describes a new release, not yet installed, that has been discovered when an ISO has been attached to
231+
// the current node
232+
InternalReleaseImageConditionTypeMounted InternalReleaseImageConditionType = "Mounted"
233+
// InternalReleaseImageConditionTypeInstalling describes a new release that is getting installed on the current node. Due the size of the data
234+
// transfered, the operation could take several minutes
235+
InternalReleaseImageConditionTypeInstalling InternalReleaseImageConditionType = "Installing"
236+
// InternalReleaseImageConditionTypeAvailable describes a release that has been successfully installed on the current node, ready to be consumed
237+
InternalReleaseImageConditionTypeAvailable InternalReleaseImageConditionType = "Available"
238+
// InternalReleaseImageConditionTypeRemoving describes an existing release that is getting removed from the current node
239+
InternalReleaseImageConditionTypeRemoving InternalReleaseImageConditionType = "Removing"
240+
// InternalReleaseImageConditionTypeDegraded describes a failure for the current release
241+
InternalReleaseImageConditionTypeDegraded InternalReleaseImageConditionType = "Degraded"
242+
)
243+
163244
// IrreconcilableChangeDiff holds an individual diff between the initial install-time MachineConfig
164245
// and the latest applied one caused by the presence of irreconcilable changes.
165246
type IrreconcilableChangeDiff struct {

0 commit comments

Comments
 (0)