From b824ff70ce84a5e0fbfc08939cf5825752a80053 Mon Sep 17 00:00:00 2001 From: Damiano Donati Date: Fri, 8 Nov 2024 19:17:22 +0100 Subject: [PATCH] machine-api: disallow unsetting authoritativeAPI --- machine/v1beta1/types_machineset.go | 1 + .../0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml | 2 ++ .../machinesets.machine.openshift.io/MachineAPIMigration.yaml | 2 ++ 3 files changed, 5 insertions(+) diff --git a/machine/v1beta1/types_machineset.go b/machine/v1beta1/types_machineset.go index a14d50eb784..4b2d3058e75 100644 --- a/machine/v1beta1/types_machineset.go +++ b/machine/v1beta1/types_machineset.go @@ -112,6 +112,7 @@ type MachineTemplateSpec struct { // MachineSetStatus defines the observed state of MachineSet // +openshift:validation:FeatureGateAwareXValidation:featureGate=MachineAPIMigration,rule="!has(oldSelf.synchronizedGeneration) || (has(self.synchronizedGeneration) && self.synchronizedGeneration >= oldSelf.synchronizedGeneration) || (oldSelf.authoritativeAPI == 'Migrating' && self.authoritativeAPI != 'Migrating')",message="synchronizedGeneration must not decrease unless authoritativeAPI is transitioning from Migrating to another value" +// +openshift:validation:FeatureGateAwareXValidation:featureGate=MachineAPIMigration,rule="self.authoritativeAPI != ” || oldSelf.authoritativeAPI == ”",message="authoritativeAPI cannot be unset once it has been set" type MachineSetStatus struct { // Replicas is the most recently observed number of replicas. Replicas int32 `json:"replicas"` diff --git a/machine/v1beta1/zz_generated.crd-manifests/0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml b/machine/v1beta1/zz_generated.crd-manifests/0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml index 48b77e0d955..e880a8c8709 100644 --- a/machine/v1beta1/zz_generated.crd-manifests/0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml +++ b/machine/v1beta1/zz_generated.crd-manifests/0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml @@ -692,6 +692,8 @@ spec: && self.synchronizedGeneration >= oldSelf.synchronizedGeneration) || (oldSelf.authoritativeAPI == ''Migrating'' && self.authoritativeAPI != ''Migrating'')' + - message: authoritativeAPI cannot be unset once it has been set + rule: self.authoritativeAPI != ” || oldSelf.authoritativeAPI == ” type: object served: true storage: true diff --git a/machine/v1beta1/zz_generated.featuregated-crd-manifests/machinesets.machine.openshift.io/MachineAPIMigration.yaml b/machine/v1beta1/zz_generated.featuregated-crd-manifests/machinesets.machine.openshift.io/MachineAPIMigration.yaml index 4954d9fbba6..fc906826071 100644 --- a/machine/v1beta1/zz_generated.featuregated-crd-manifests/machinesets.machine.openshift.io/MachineAPIMigration.yaml +++ b/machine/v1beta1/zz_generated.featuregated-crd-manifests/machinesets.machine.openshift.io/MachineAPIMigration.yaml @@ -692,6 +692,8 @@ spec: && self.synchronizedGeneration >= oldSelf.synchronizedGeneration) || (oldSelf.authoritativeAPI == ''Migrating'' && self.authoritativeAPI != ''Migrating'')' + - message: authoritativeAPI cannot be unset once it has been set + rule: self.authoritativeAPI != ” || oldSelf.authoritativeAPI == ” type: object served: true storage: true