Skip to content
Merged
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
1 change: 1 addition & 0 deletions machineconfiguration/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ type MachineConfigPoolSpec struct {
// +optional
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=100
PinnedImageSets []PinnedImageSetRef `json:"pinnedImageSets,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ spec:
required:
- name
type: object
maxItems: 100
type: array
x-kubernetes-list-map-keys:
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ spec:
required:
- name
type: object
maxItems: 100
type: array
x-kubernetes-list-map-keys:
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ spec:
required:
- name
type: object
maxItems: 100
type: array
x-kubernetes-list-map-keys:
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,170 @@ tests:
node:
name: foobar
expectedError: "spec.configVersion: Required value, <nil>: Invalid value: \"null\""
- name: Should be able to create a MachineConfigNode with a PinnedImageSet
initial: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
expected: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
onUpdate:
- name: PinnedImageSet desired generation must be greater than or equal to the current generation
initial: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 1
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
currentGeneration: 1
desiredGeneration: 1
updated: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 1
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
currentGeneration: 2
desiredGeneration: 1
expectedStatusError: "Invalid value: \"object\": desired generation must be greater than or equal to the current generation"
- name: PinnedImageSet desired generation must be greater than last failed generation
initial: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 4
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
currentGeneration: 2
desiredGeneration: 2
lastFailedGeneration: 1
updated: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 5
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
currentGeneration: 3
desiredGeneration: 3
lastFailedGeneration: 4
expectedStatusError: "Invalid value: \"object\": desired generation must be greater than last failed generation"
- name: PinnedImageSet desired generation must be set if last failed generation is set
initial: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 4
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
updated: |
apiVersion: machineconfiguration.openshift.io/v1alpha1
kind: MachineConfigNode
metadata:
name: foobar
spec:
node:
name: foobar
pool:
name: worker
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
status:
observedGeneration: 5
configVersion:
desired: rendered-worker-abc
pinnedImageSets:
- name: test-pinned-image-set
lastFailedGeneration: 2
expectedStatusError: "Invalid value: \"object\": desired generation must be defined if last failed generation is defined"
59 changes: 59 additions & 0 deletions machineconfiguration/v1alpha1/types_machineconfignode.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ type MachineConfigNodeSpec struct {
// the new machine config against the current machine config.
// +kubebuilder:validation:Required
ConfigVersion MachineConfigNodeSpecMachineConfigVersion `json:"configVersion"`

// pinnedImageSets holds the desired pinned image sets that this node should pin and pull.
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=100
// +optional
PinnedImageSets []MachineConfigNodeSpecPinnedImageSet `json:"pinnedImageSets,omitempty"`
}

// MachineConfigNodeStatus holds the reported information on a particular machine config node.
Expand All @@ -107,6 +114,43 @@ type MachineConfigNodeStatus struct {
// This desired machine config has been compared to the current machine config and has been validated by the machine config operator as one that is valid and that exists.
// +kubebuilder:validation:Required
ConfigVersion MachineConfigNodeStatusMachineConfigVersion `json:"configVersion"`
// pinnedImageSets describes the current and desired pinned image sets for this node.
// The current version is the generation of the pinned image set that has most recently been successfully pulled and pinned on this node.
// The desired version is the generation of the pinned image set that is targeted to be pulled and pinned on this node.
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=100
// +optional
PinnedImageSets []MachineConfigNodeStatusPinnedImageSet `json:"pinnedImageSets,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="has(self.desiredGeneration) && has(self.currentGeneration) ? self.desiredGeneration >= self.currentGeneration : true",message="desired generation must be greater than or equal to the current generation"
// +kubebuilder:validation:XValidation:rule="has(self.lastFailedGeneration) && has(self.desiredGeneration) ? self.desiredGeneration >= self.lastFailedGeneration : true",message="desired generation must be greater than last failed generation"
// +kubebuilder:validation:XValidation:rule="has(self.lastFailedGeneration) ? has(self.desiredGeneration): true",message="desired generation must be defined if last failed generation is defined"
type MachineConfigNodeStatusPinnedImageSet struct {
// name is the name of the pinned image set.
// Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
// It may consist of only alphanumeric characters, hyphens (-) and periods (.)
// and must be at most 253 characters in length.
// +kubebuilder:validation:MaxLength:=253
// +kubebuilder:validation:Pattern=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
// +kubebuilder:validation:Required
Name string `json:"name"`
Comment thread
deads2k marked this conversation as resolved.
// currentGeneration is the generation of the pinned image set that has most recently been successfully pulled and pinned on this node.
// +optional
CurrentGeneration int32 `json:"currentGeneration,omitempty"`
// desiredGeneration version is the generation of the pinned image set that is targeted to be pulled and pinned on this node.
// +kubebuilder:validation:Minimum=0
// +optional
DesiredGeneration int32 `json:"desiredGeneration,omitempty"`
Comment thread
hexfusion marked this conversation as resolved.
Comment thread
hexfusion marked this conversation as resolved.
// lastFailedGeneration is the generation of the most recent pinned image set that failed to be pulled and pinned on this node.
// +kubebuilder:validation:Minimum=0
// +optional
LastFailedGeneration int32 `json:"lastFailedGeneration,omitempty"`
Comment thread
hexfusion marked this conversation as resolved.
// lastFailedGenerationErrors is a list of errors why the lastFailed generation failed to be pulled and pinned.
// +kubebuilder:validation:MaxItems=10
// +optional
LastFailedGenerationErrors []string `json:"lastFailedGenerationErrors,omitempty"`
Comment thread
hexfusion marked this conversation as resolved.
}

// MachineConfigNodeStatusMachineConfigVersion holds the current and desired config versions as last updated in the MCN status.
Expand Down Expand Up @@ -155,6 +199,17 @@ type MachineConfigNodeSpecMachineConfigVersion struct {
Desired string `json:"desired"`
}

type MachineConfigNodeSpecPinnedImageSet struct {
// name is the name of the pinned image set.
// Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
// It may consist of only alphanumeric characters, hyphens (-) and periods (.)
// and must be at most 253 characters in length.
// +kubebuilder:validation:MaxLength:=253
// +kubebuilder:validation:Pattern=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
// +kubebuilder:validation:Required
Name string `json:"name"`
}

// StateProgress is each possible state for each possible MachineConfigNodeType
// UpgradeProgression Kind will only use the "MachinConfigPoolUpdate..." types for example
// Please note: These conditions are subject to change. Both additions and deletions may be made.
Expand Down Expand Up @@ -187,4 +242,8 @@ const (
MachineConfigNodeUpdateRebooted StateProgress = "RebootedNode"
// MachineConfigNodeUpdateReloaded describes the part of the post action phase where the node reloads its CRIO service
MachineConfigNodeUpdateReloaded StateProgress = "ReloadedCRIO"
// MachineConfigNodePinnedImageSetsProgressing describes a machine currently progressing to the desired pinned image sets
MachineConfigNodePinnedImageSetsProgressing StateProgress = "PinnedImageSetsProgressing"
// MachineConfigNodePinnedImageSetsDegraded describes a machine that has failed to progress to the desired pinned image sets
MachineConfigNodePinnedImageSetsDegraded StateProgress = "PinnedImageSetsDegraded"
)
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ spec:
required:
- name
type: object
pinnedImageSets:
description: pinnedImageSets holds the desired pinned image sets that
this node should pin and pull.
items:
properties:
name:
description: name is the name of the pinned image set. Must
be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
It may consist of only alphanumeric characters, hyphens (-)
and periods (.) and must be at most 253 characters in length.
maxLength: 253
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
required:
- name
type: object
maxItems: 100
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
pool:
description: pool contains a reference to the machine config pool
that this machine config node's referenced node belongs to.
Expand Down Expand Up @@ -266,6 +287,70 @@ spec:
config node spec.
format: int64
type: integer
pinnedImageSets:
description: pinnedImageSets describes the current and desired pinned
image sets for this node. The current version is the generation
of the pinned image set that has most recently been successfully
pulled and pinned on this node. The desired version is the generation
of the pinned image set that is targeted to be pulled and pinned
on this node.
items:
properties:
currentGeneration:
description: currentGeneration is the generation of the pinned
image set that has most recently been successfully pulled
and pinned on this node.
format: int32
type: integer
desiredGeneration:
description: desiredGeneration version is the generation of
the pinned image set that is targeted to be pulled and pinned
on this node.
format: int32
minimum: 0
type: integer
lastFailedGeneration:
description: lastFailedGeneration is the generation of the most
recent pinned image set that failed to be pulled and pinned
on this node.
format: int32
minimum: 0
type: integer
lastFailedGenerationErrors:
description: lastFailedGenerationErrors is a list of errors
why the lastFailed generation failed to be pulled and pinned.
items:
type: string
maxItems: 10
type: array
name:
description: name is the name of the pinned image set. Must
be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
It may consist of only alphanumeric characters, hyphens (-)
and periods (.) and must be at most 253 characters in length.
maxLength: 253
pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$
type: string
required:
- name
type: object
x-kubernetes-validations:
- message: desired generation must be greater than or equal to the
current generation
rule: 'has(self.desiredGeneration) && has(self.currentGeneration)
? self.desiredGeneration >= self.currentGeneration : true'
- message: desired generation must be greater than last failed generation
rule: 'has(self.lastFailedGeneration) && has(self.desiredGeneration)
? self.desiredGeneration >= self.lastFailedGeneration : true'
- message: desired generation must be defined if last failed generation
is defined
rule: 'has(self.lastFailedGeneration) ? has(self.desiredGeneration):
true'
maxItems: 100
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
required:
- configVersion
type: object
Expand Down
Loading