From 426d59473937ba3aaec1e6ef768051090d1c78ac Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Wed, 29 Mar 2023 13:36:31 -0600 Subject: [PATCH] STOR-1266: Add CSI migration option to Storage operator spec --- .../generated_openapi/zz_generated.openapi.go | 8 ++ openapi/openapi.json | 5 ++ ...00_50_cluster_storage_operator_01_crd.yaml | 13 +++ operator/v1/stable.storage.testsuite.yaml | 88 +++++++++++++++++++ operator/v1/types_storage.go | 19 ++++ .../v1/zz_generated.swagger_doc_generated.go | 3 +- 6 files changed, 135 insertions(+), 1 deletion(-) diff --git a/openapi/generated_openapi/zz_generated.openapi.go b/openapi/generated_openapi/zz_generated.openapi.go index abba39aa75d..134f1a7f353 100644 --- a/openapi/generated_openapi/zz_generated.openapi.go +++ b/openapi/generated_openapi/zz_generated.openapi.go @@ -46544,6 +46544,14 @@ func schema_openshift_api_operator_v1_StorageSpec(ref common.ReferenceCallback) Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "vsphereStorageDriver": { + SchemaProps: spec.SchemaProps{ + Description: "VSphereStorageDriver indicates the storage driver to use on VSphere clusters. Once this field is set to CSIWithMigrationDriver, it can not be changed. If this is empty, the platform will choose a good default, which may change over time without notice. DEPRECATED: This field will be removed in a future release.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, }, Required: []string{"managementState"}, }, diff --git a/openapi/openapi.json b/openapi/openapi.json index 85220f89928..09c9a26ea02 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -27274,6 +27274,11 @@ "description": "unsupportedConfigOverrides overrides the final configuration that was computed by the operator. Red Hat does not support the use of this field. Misuse of this field could lead to unexpected behavior or conflict with other configuration options. Seek guidance from the Red Hat support before using this field. Use of this property blocks cluster upgrades, it must be removed before upgrading your cluster.", "default": {}, "$ref": "#/definitions/io.k8s.apimachinery.pkg.runtime.RawExtension" + }, + "vsphereStorageDriver": { + "description": "VSphereStorageDriver indicates the storage driver to use on VSphere clusters. Once this field is set to CSIWithMigrationDriver, it can not be changed. If this is empty, the platform will choose a good default, which may change over time without notice. DEPRECATED: This field will be removed in a future release.", + "type": "string", + "default": "" } } }, diff --git a/operator/v1/0000_50_cluster_storage_operator_01_crd.yaml b/operator/v1/0000_50_cluster_storage_operator_01_crd.yaml index 948f42dda73..4673e2e800b 100644 --- a/operator/v1/0000_50_cluster_storage_operator_01_crd.yaml +++ b/operator/v1/0000_50_cluster_storage_operator_01_crd.yaml @@ -69,6 +69,19 @@ spec: type: object nullable: true x-kubernetes-preserve-unknown-fields: true + vsphereStorageDriver: + description: 'VSphereStorageDriver indicates the storage driver to use on VSphere clusters. Once this field is set to CSIWithMigrationDriver, it can not be changed. If this is empty, the platform will choose a good default, which may change over time without notice. DEPRECATED: This field will be removed in a future release.' + type: string + enum: + - "" + - LegacyDeprecatedInTreeDriver + - CSIWithMigrationDriver + x-kubernetes-validations: + - rule: self == oldSelf || oldSelf == "" || self == "CSIWithMigrationDriver" + message: VSphereStorageDriver can not be changed once it is set to CSIWithMigrationDriver + x-kubernetes-validations: + - rule: '!has(oldSelf.vsphereStorageDriver) || has(self.vsphereStorageDriver)' + message: VSphereStorageDriver is required once set status: description: status holds observed values from the cluster. They may not be overridden. type: object diff --git a/operator/v1/stable.storage.testsuite.yaml b/operator/v1/stable.storage.testsuite.yaml index 42903f22de3..63a7ca45437 100644 --- a/operator/v1/stable.storage.testsuite.yaml +++ b/operator/v1/stable.storage.testsuite.yaml @@ -14,3 +14,91 @@ tests: spec: logLevel: Normal operatorLogLevel: Normal + onUpdate: + - name: Should allow enabling CSI migration for vSphere + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: {} # No spec is required + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + expected: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + logLevel: Normal + operatorLogLevel: Normal + - name: Should allow disabling CSI migration for vSphere + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: {} # No spec is required + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: LegacyDeprecatedInTreeDriver + expected: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: LegacyDeprecatedInTreeDriver + logLevel: Normal + operatorLogLevel: Normal + - name: Should allow changing LegacyDeprecatedInTreeDriver to CSIWithMigrationDriver + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: LegacyDeprecatedInTreeDriver + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + expected: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + logLevel: Normal + operatorLogLevel: Normal + - name: Should not allow changing CSIWithMigrationDriver to LegacyDeprecatedInTreeDriver + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: LegacyDeprecatedInTreeDriver + expectedError: "VSphereStorageDriver can not be changed once it is set to CSIWithMigrationDriver" + - name: Should not allow changing CSIWithMigrationDriver to empty string + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: "" + expectedError: "VSphereStorageDriver can not be changed once it is set to CSIWithMigrationDriver" + - name: Should not allow unsetting VSphereStorageDriver once it is set + initial: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: + vsphereStorageDriver: CSIWithMigrationDriver + updated: | + apiVersion: operator.openshift.io/v1 + kind: Storage + spec: {} + expectedError: "VSphereStorageDriver is required once set" diff --git a/operator/v1/types_storage.go b/operator/v1/types_storage.go index 38ffe26d528..044c9c32ae6 100644 --- a/operator/v1/types_storage.go +++ b/operator/v1/types_storage.go @@ -26,9 +26,28 @@ type Storage struct { Status StorageStatus `json:"status"` } +// StorageDriverType indicates whether CSI migration should be enabled for drivers where it is optional. +// +kubebuilder:validation:Enum="";LegacyDeprecatedInTreeDriver;CSIWithMigrationDriver +type StorageDriverType string + +const ( + LegacyDeprecatedInTreeDriver StorageDriverType = "LegacyDeprecatedInTreeDriver" + CSIWithMigrationDriver StorageDriverType = "CSIWithMigrationDriver" +) + // StorageSpec is the specification of the desired behavior of the cluster storage operator. +// +kubebuilder:validation:XValidation:rule="!has(oldSelf.vsphereStorageDriver) || has(self.vsphereStorageDriver)", message="VSphereStorageDriver is required once set" type StorageSpec struct { OperatorSpec `json:",inline"` + + // VSphereStorageDriver indicates the storage driver to use on VSphere clusters. + // Once this field is set to CSIWithMigrationDriver, it can not be changed. + // If this is empty, the platform will choose a good default, + // which may change over time without notice. + // DEPRECATED: This field will be removed in a future release. + // +kubebuilder:validation:XValidation:rule="self == oldSelf || oldSelf == \"\" || self == \"CSIWithMigrationDriver\"",message="VSphereStorageDriver can not be changed once it is set to CSIWithMigrationDriver" + // +optional + VSphereStorageDriver StorageDriverType `json:"vsphereStorageDriver"` } // StorageStatus defines the observed status of the cluster storage operator. diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index 0c76b27aa5c..8e9c5d74f79 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -1610,7 +1610,8 @@ func (StorageList) SwaggerDoc() map[string]string { } var map_StorageSpec = map[string]string{ - "": "StorageSpec is the specification of the desired behavior of the cluster storage operator.", + "": "StorageSpec is the specification of the desired behavior of the cluster storage operator.", + "vsphereStorageDriver": "VSphereStorageDriver indicates the storage driver to use on VSphere clusters. Once this field is set to CSIWithMigrationDriver, it can not be changed. If this is empty, the platform will choose a good default, which may change over time without notice. DEPRECATED: This field will be removed in a future release.", } func (StorageSpec) SwaggerDoc() map[string]string {