Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[FeatureGate] ImageModeStatusReporting"
crdName: machineconfignodes.machineconfiguration.openshift.io
featureGates:
- ImageModeStatusReporting
tests:
onCreate:
- name: Should be able to create MachineConfigNode when spec.configImage ImageModeStatusReporting is enabled
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
expected: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
- name: spec.configImage.desiredImage should enforce MaxLength.
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
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
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
- name: Should not be able to create a MachineConfigNode with desiredImage set to a tag-based image reference
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/os-images:latest
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
- name: spec.configImage.desiredImage should enforce 256 image digest format.
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/os-images@sha512:a2c24b2903ad327e06bf57ac1d34e4e99e284309ccc69a5ffcc640121c0f82a05a841e915edb1b633ca52692bd019e1fcdd09d3f0730ace8f49c96b3bd020216
expectedError: "the OCI Image reference must end with a valid '@sha256:<digest>' suffix, where '<digest>' is 64 characters long"
onUpdate:
- name: Should be able to create MachineConfigNode with status.configImage when ImageModeStatusReporting is enabled when the current and desired images are the same
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
updated: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
status:
configImage:
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
expected: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
status:
configImage:
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
- name: Should be able to create MachineConfigNode with status.configImage when ImageModeStatusReporting is enabled when the current and desired images are the different.
initial: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
updated: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
status:
configImage:
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:c47856f56e1fdb7c9d10a1658e4ea85fbea44d71fb0e82898d152b47e0f894c6
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
expected: |
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigNode
metadata:
name: test-imagemodestatusreporting
spec:
node:
name: test-imagemodestatusreporting
pool:
name: worker
configVersion:
desired: rendered-worker-abc
configImage:
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6
status:
configImage:
currentImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:c47856f56e1fdb7c9d10a1658e4ea85fbea44d71fb0e82898d152b47e0f894c6
desiredImage: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/ocb-image@sha256:7a539f562d8d5d3b6bd7338ac014e34dabc9626cf344d30e412ef98a55cc1bf6

59 changes: 59 additions & 0 deletions machineconfiguration/v1/types_machineconfignode.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ type MachineConfigNodeSpec struct {
// the new machine config against the current machine config.
// +required
ConfigVersion MachineConfigNodeSpecMachineConfigVersion `json:"configVersion"`

// 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
// 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.
// 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.
// +openshift:enable:FeatureGate=ImageModeStatusReporting
// +optional
ConfigImage MachineConfigNodeSpecConfigImage `json:"configImage,omitempty,omitzero"`
}

// MachineConfigNodeStatus holds the reported information on a particular machine config node.
Expand All @@ -106,6 +113,8 @@ type MachineConfigNodeStatus struct {
// UpdatePrepared, UpdateExecuted, UpdatePostActionComplete, UpdateComplete, Updated, Resumed,
// Drained, AppliedFilesAndOS, Cordoned, Uncordoned, RebootedNode, NodeDegraded, PinnedImageSetsProgressing,
// and PinnedImageSetsDegraded.
// The following types are only available when the ImageModeStatusReporting feature gate is enabled: ImagePulledFromRegistry,
// AppliedOSImage, AppliedFiles
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=20
Expand All @@ -120,6 +129,15 @@ type MachineConfigNodeStatus struct {
// configVersion describes the current and desired machine config version for this node.
// +optional
ConfigVersion *MachineConfigNodeStatusMachineConfigVersion `json:"configVersion,omitempty"`
// 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.
// 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.
// When specified, the Image Mode feature is enabled and the contents of this field show the observed state of the node image.
// 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.
// 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
// and configVersion change during the same update.
// +openshift:enable:FeatureGate=ImageModeStatusReporting
// +optional
ConfigImage MachineConfigNodeStatusConfigImage `json:"configImage,omitempty,omitzero"`
// pinnedImageSets describes the current and desired pinned image sets for this node.
// +listType=map
// +listMapKey=name
Expand Down Expand Up @@ -244,6 +262,41 @@ type MachineConfigNodeSpecMachineConfigVersion struct {
Desired string `json:"desired"`
}

// MachineConfigNodeSpecConfigImage holds the desired image for the node.
// This structure is populated from the `machineconfiguration.openshift.io/desiredImage`
// annotation on the target node, which is set by the Machine Config Pool controller
// to signal the desired image pullspec for the node to update to.
type MachineConfigNodeSpecConfigImage struct {
// desiredImage is a required field that configures the image that the node should be updated to use.
// 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.
// desiredImage must not be an empty string and must not exceed 447 characters in length.
// +required
DesiredImage ImageDigestFormat `json:"desiredImage,omitempty"`
}

// MachineConfigNodeStatusConfigImage holds the observed state of the image
// on the node, including both the image targeted for an update and the image
// currently applied. This allows for monitoring the progress of the layering
// rollout. If Image Mode is enabled, desiredImage must be defined.
// +kubebuilder:validation:MinProperties:=1
type MachineConfigNodeStatusConfigImage struct {
// currentImage is an optional field that represents the current image that is applied to the node.
// 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.
// When specified, this means that the node is currently using this image.
// 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.
// currentImage must not be an empty string and must not exceed 447 characters in length.
// +optional
CurrentImage ImageDigestFormat `json:"currentImage,omitzero,omitempty"`
// desiredImage is an optional field that represents the currently observed state of image that the node should be updated to use.
// 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.
// When specified, this means that Image Mode has been enabled and the node is actively progressing to update the node to this image.
// If currentImage and desiredImage match, the node has been successfully updated to use the desired image.
// 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.
// desiredImage must not be an empty string and must not exceed 447 characters in length.
// +optional
DesiredImage ImageDigestFormat `json:"desiredImage,omitzero,omitempty"`
}

// StateProgress is each possible state for each possible MachineConfigNodeType
// +enum
type StateProgress string
Expand All @@ -263,8 +316,14 @@ const (
MachineConfigNodeResumed StateProgress = "Resumed"
// MachineConfigNodeUpdateDrained describes the part of the in progress phase where the node drains
MachineConfigNodeUpdateDrained StateProgress = "Drained"
// MachineConfigNodeUpdateFiles describes the part of the in progress phase where the nodes files changes
MachineConfigNodeUpdateFiles StateProgress = "AppliedFiles"
// MachineConfigNodeUpdateOS describes the part of the in progress phase where the OS config changes
MachineConfigNodeUpdateOS StateProgress = "AppliedOSImage"
// MachineConfigNodeUpdateFilesAndOS describes the part of the in progress phase where the nodes files and OS config change
MachineConfigNodeUpdateFilesAndOS StateProgress = "AppliedFilesAndOS"
// MachineConfigNodeImagePulledFromRegistry describes the part of the in progress phase where the update image is pulled from the registry
MachineConfigNodeImagePulledFromRegistry StateProgress = "ImagePulledFromRegistry"
// MachineConfigNodeUpdateCordoned describes the part of the in progress phase where the node cordons
MachineConfigNodeUpdateCordoned StateProgress = "Cordoned"
// MachineConfigNodeUpdateUncordoned describes the part of the completing phase where the node uncordons
Expand Down
Loading