diff --git a/api/hypershift/v1beta1/nodepool_types.go b/api/hypershift/v1beta1/nodepool_types.go index c7040ce8dc85..750360bffee5 100644 --- a/api/hypershift/v1beta1/nodepool_types.go +++ b/api/hypershift/v1beta1/nodepool_types.go @@ -101,6 +101,7 @@ type NodePool struct { } // NodePoolSpec is the desired behavior of a NodePool. +// +openshift:validation:FeatureGateAwareXValidation:featureGate=OSStreams,rule="!has(oldSelf.osImageStream) || has(self.osImageStream)",message="osImageStream cannot be removed once set; create a new NodePool instead" // +kubebuilder:validation:XValidation:rule="!has(oldSelf.arch) || has(self.arch)", message="Arch is required once set" // +kubebuilder:validation:XValidation:rule="self.arch != 'arm64' || has(self.platform.aws) || has(self.platform.azure) || has(self.platform.agent) || self.platform.type == 'GCP' || self.platform.type == 'None'", message="Setting Arch to arm64 is only supported for AWS, Azure, Agent, GCP and None" // +kubebuilder:validation:XValidation:rule="!has(self.replicas) || !has(self.autoScaling)", message="Both replicas or autoScaling should not be set" @@ -261,6 +262,13 @@ type NodePoolSpec struct { OSImageStream OSImageStreamReference `json:"osImageStream,omitzero"` } +const ( + // OSImageStreamRHEL9 is the OS image stream name for RHEL 9. + OSImageStreamRHEL9 = "rhel-9" + // OSImageStreamRHEL10 is the OS image stream name for RHEL 10. + OSImageStreamRHEL10 = "rhel-10" +) + // OSImageStreamReference references an OSImageStream by name. type OSImageStreamReference struct { // name is a required reference to an OSImageStream to be used for the pool. diff --git a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml index 686feae62fab..9b837d2a6985 100644 --- a/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml +++ b/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OSStreams.yaml @@ -1528,6 +1528,9 @@ spec: - release type: object x-kubernetes-validations: + - message: osImageStream cannot be removed once set; create a new NodePool + instead + rule: '!has(oldSelf.osImageStream) || has(self.osImageStream)' - message: Arch is required once set rule: '!has(oldSelf.arch) || has(self.arch)' - message: Setting Arch to arm64 is only supported for AWS, Azure, Agent, diff --git a/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/featuregated.nodepools.osimagestream.testsuite.yaml b/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/featuregated.nodepools.osimagestream.testsuite.yaml index 5d15bd83cdaf..879d7508cee0 100644 --- a/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/featuregated.nodepools.osimagestream.testsuite.yaml +++ b/cmd/install/assets/crds/hypershift-operator/tests/nodepools.hypershift.openshift.io/featuregated.nodepools.osimagestream.testsuite.yaml @@ -187,6 +187,55 @@ tests: osImageStream: name: "rhel-10" + - name: When removing osImageStream from an existing NodePool it should fail + initial: | + apiVersion: hypershift.openshift.io/v1beta1 + kind: NodePool + spec: + arch: amd64 + clusterName: some-cluster + management: + autoRepair: false + upgradeType: Replace + release: + image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 + replicas: 0 + platform: + aws: + instanceProfile: a-profile + instanceType: m6a.2xlarge + rootVolume: + size: 120 + type: gp3 + subnet: + id: "subnet-any" + type: AWS + osImageStream: + name: "rhel-10" + updated: | + apiVersion: hypershift.openshift.io/v1beta1 + kind: NodePool + spec: + arch: amd64 + clusterName: some-cluster + management: + autoRepair: false + upgradeType: Replace + release: + image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 + replicas: 0 + platform: + aws: + instanceProfile: a-profile + instanceType: m6a.2xlarge + rootVolume: + size: 120 + type: gp3 + subnet: + id: "subnet-any" + type: AWS + expectedError: "osImageStream cannot be removed once set; create a new NodePool instead" + - name: When adding osImageStream to an existing NodePool it should succeed initial: | apiVersion: hypershift.openshift.io/v1beta1 diff --git a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml index 5b7938038b03..a46fb821ef5d 100644 --- a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml +++ b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml @@ -1993,6 +1993,9 @@ spec: - release type: object x-kubernetes-validations: + - message: osImageStream cannot be removed once set; create a new NodePool + instead + rule: '!has(oldSelf.osImageStream) || has(self.osImageStream)' - message: Arch is required once set rule: '!has(oldSelf.arch) || has(self.arch)' - message: Setting Arch to arm64 is only supported for AWS, Azure, Agent, diff --git a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml index 4d15644f9fb5..a9419620c9db 100644 --- a/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml +++ b/cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml @@ -1993,6 +1993,9 @@ spec: - release type: object x-kubernetes-validations: + - message: osImageStream cannot be removed once set; create a new NodePool + instead + rule: '!has(oldSelf.osImageStream) || has(self.osImageStream)' - message: Arch is required once set rule: '!has(oldSelf.arch) || has(self.arch)' - message: Setting Arch to arm64 is only supported for AWS, Azure, Agent, diff --git a/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/nodepool_types.go b/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/nodepool_types.go index c7040ce8dc85..750360bffee5 100644 --- a/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/nodepool_types.go +++ b/vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/nodepool_types.go @@ -101,6 +101,7 @@ type NodePool struct { } // NodePoolSpec is the desired behavior of a NodePool. +// +openshift:validation:FeatureGateAwareXValidation:featureGate=OSStreams,rule="!has(oldSelf.osImageStream) || has(self.osImageStream)",message="osImageStream cannot be removed once set; create a new NodePool instead" // +kubebuilder:validation:XValidation:rule="!has(oldSelf.arch) || has(self.arch)", message="Arch is required once set" // +kubebuilder:validation:XValidation:rule="self.arch != 'arm64' || has(self.platform.aws) || has(self.platform.azure) || has(self.platform.agent) || self.platform.type == 'GCP' || self.platform.type == 'None'", message="Setting Arch to arm64 is only supported for AWS, Azure, Agent, GCP and None" // +kubebuilder:validation:XValidation:rule="!has(self.replicas) || !has(self.autoScaling)", message="Both replicas or autoScaling should not be set" @@ -261,6 +262,13 @@ type NodePoolSpec struct { OSImageStream OSImageStreamReference `json:"osImageStream,omitzero"` } +const ( + // OSImageStreamRHEL9 is the OS image stream name for RHEL 9. + OSImageStreamRHEL9 = "rhel-9" + // OSImageStreamRHEL10 is the OS image stream name for RHEL 10. + OSImageStreamRHEL10 = "rhel-10" +) + // OSImageStreamReference references an OSImageStream by name. type OSImageStreamReference struct { // name is a required reference to an OSImageStream to be used for the pool.