From 6a286acd242f020fdbea864477ed2938121adad3 Mon Sep 17 00:00:00 2001 From: Deepak Kinni Date: Thu, 1 Aug 2024 17:43:10 -0700 Subject: [PATCH] Introduce FSS supervisor-block-volume-snapshot for CSI Snapshot support on Supervisor Signed-off-by: Deepak Kinni --- manifests/supervisorcluster/1.27/cns-csi.yaml | 1 + manifests/supervisorcluster/1.28/cns-csi.yaml | 1 + manifests/supervisorcluster/1.29/cns-csi.yaml | 1 + pkg/csi/service/common/constants.go | 2 ++ pkg/syncer/admissionhandler/admissionhandler.go | 16 +++++++++------- .../validatesnapshotoperation.go | 5 +++-- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/manifests/supervisorcluster/1.27/cns-csi.yaml b/manifests/supervisorcluster/1.27/cns-csi.yaml index 1f21e95b88..a11ad0bcce 100644 --- a/manifests/supervisorcluster/1.27/cns-csi.yaml +++ b/manifests/supervisorcluster/1.27/cns-csi.yaml @@ -464,6 +464,7 @@ data: "storage-quota-m2": "false" "vdpp-on-stretched-supervisor": "false" "cns-unregister-volume": "false" + "supervisor-block-volume-snapshot": "false" kind: ConfigMap metadata: name: csi-feature-states diff --git a/manifests/supervisorcluster/1.28/cns-csi.yaml b/manifests/supervisorcluster/1.28/cns-csi.yaml index 1f21e95b88..a11ad0bcce 100644 --- a/manifests/supervisorcluster/1.28/cns-csi.yaml +++ b/manifests/supervisorcluster/1.28/cns-csi.yaml @@ -464,6 +464,7 @@ data: "storage-quota-m2": "false" "vdpp-on-stretched-supervisor": "false" "cns-unregister-volume": "false" + "supervisor-block-volume-snapshot": "false" kind: ConfigMap metadata: name: csi-feature-states diff --git a/manifests/supervisorcluster/1.29/cns-csi.yaml b/manifests/supervisorcluster/1.29/cns-csi.yaml index 1f21e95b88..a11ad0bcce 100644 --- a/manifests/supervisorcluster/1.29/cns-csi.yaml +++ b/manifests/supervisorcluster/1.29/cns-csi.yaml @@ -464,6 +464,7 @@ data: "storage-quota-m2": "false" "vdpp-on-stretched-supervisor": "false" "cns-unregister-volume": "false" + "supervisor-block-volume-snapshot": "false" kind: ConfigMap metadata: name: csi-feature-states diff --git a/pkg/csi/service/common/constants.go b/pkg/csi/service/common/constants.go index 7f905fb0ad..09720fb817 100644 --- a/pkg/csi/service/common/constants.go +++ b/pkg/csi/service/common/constants.go @@ -423,6 +423,8 @@ const ( CSIDetachOnSupervisor = "CSI_Detach_Supported" // CnsUnregisterVolume enables the cretion of CRD and controller for CnsUnregisterVolume API. CnsUnregisterVolume = "cns-unregister-volume" + // SupervisorBlockVolumeSnapshots enables the creation of CSI snapshots on supervisor directly. + SupervisorBlockVolumeSnapshots = "supervisor-block-volume-snapshot" ) var WCPFeatureStates = map[string]struct{}{ diff --git a/pkg/syncer/admissionhandler/admissionhandler.go b/pkg/syncer/admissionhandler/admissionhandler.go index 20f3ca31d8..e02d706a7f 100644 --- a/pkg/syncer/admissionhandler/admissionhandler.go +++ b/pkg/syncer/admissionhandler/admissionhandler.go @@ -54,13 +54,14 @@ var ( cfg *config // COInitParams stores the input params required for initiating the // CO agnostic orchestrator in the admission handler package. - COInitParams *interface{} - featureGateCsiMigrationEnabled bool - featureGateBlockVolumeSnapshotEnabled bool - featureGateTKGSHaEnabled bool - featureGateVolumeHealthEnabled bool - featureGateTopologyAwareFileVolumeEnabled bool - featureGateStorageQuotaM2Enabled bool + COInitParams *interface{} + featureGateCsiMigrationEnabled bool + featureGateBlockVolumeSnapshotEnabled bool + featureGateTKGSHaEnabled bool + featureGateVolumeHealthEnabled bool + featureGateTopologyAwareFileVolumeEnabled bool + featureGateStorageQuotaM2Enabled bool + featureGateSupervisorBlockVolumeSnapshotEnabled bool ) // watchConfigChange watches on the webhook configuration directory for changes @@ -144,6 +145,7 @@ func StartWebhookServer(ctx context.Context) error { featureGateVolumeHealthEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.VolumeHealth) featureGateBlockVolumeSnapshotEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) featureGateStorageQuotaM2Enabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.StorageQuotaM2) + featureGateSupervisorBlockVolumeSnapshotEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.SupervisorBlockVolumeSnapshots) startCNSCSIWebhookManager(ctx) } else if clusterFlavor == cnstypes.CnsClusterFlavorGuest { featureGateBlockVolumeSnapshotEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) diff --git a/pkg/syncer/admissionhandler/validatesnapshotoperation.go b/pkg/syncer/admissionhandler/validatesnapshotoperation.go index d2b7dcd05f..6b750bc05d 100644 --- a/pkg/syncer/admissionhandler/validatesnapshotoperation.go +++ b/pkg/syncer/admissionhandler/validatesnapshotoperation.go @@ -38,8 +38,9 @@ func validateSnapshotOperationSupervisorRequest(ctx context.Context, request adm if request.Operation == admissionv1.Create { // NOTE: Change to allow snapshot creation from supervisor directly with StorageQuotaM2 FSS enabled // is temporary & will be reverted before release - if featureGateStorageQuotaM2Enabled { - log.Debugf("validateSnapshotOperationSupervisorRequest Allow %v since StorageQuotaM2 FSS enabled", request) + if featureGateStorageQuotaM2Enabled || featureGateSupervisorBlockVolumeSnapshotEnabled { + log.Debugf("validateSnapshotOperationSupervisorRequest Allow %v since "+ + "StorageQuotaM2 or supervisor-block-volume-snapshot FSS enabled", request) return admission.Allowed("") } if _, annotationFound := newVS.Annotations[common.SupervisorVolumeSnapshotAnnotationKey]; !annotationFound {