From 04c756b5e341f02d81e91e2d85c08d28ce5a1882 Mon Sep 17 00:00:00 2001 From: John Cho Date: Fri, 4 Jul 2025 17:24:54 -0700 Subject: [PATCH] Remove csi-migration fss --- pkg/common/unittestcommon/utils.go | 1 - .../k8sorchestrator/k8sorchestrator.go | 5 +- pkg/csi/service/common/constants.go | 2 - pkg/csi/service/common/util.go | 80 ++++++--------- pkg/csi/service/common/util_test.go | 61 +----------- pkg/csi/service/vanilla/controller.go | 70 ++++--------- .../admissionhandler/admissionhandler.go | 4 +- .../admissionhandler/validatestorageclass.go | 7 -- .../validatestorageclass_test.go | 3 - pkg/syncer/fullsync.go | 3 +- pkg/syncer/metadatasyncer.go | 98 ++++++------------- pkg/syncer/util.go | 18 +--- 12 files changed, 95 insertions(+), 257 deletions(-) diff --git a/pkg/common/unittestcommon/utils.go b/pkg/common/unittestcommon/utils.go index 9b496c0dc9..60e2b32fce 100644 --- a/pkg/common/unittestcommon/utils.go +++ b/pkg/common/unittestcommon/utils.go @@ -61,7 +61,6 @@ func GetFakeContainerOrchestratorInterface(orchestratorType int) (commonco.COCom fakeCO := &FakeK8SOrchestrator{ featureStatesLock: &sync.RWMutex{}, featureStates: map[string]string{ - "csi-migration": "true", "file-volume": "true", "block-volume-snapshot": "true", "tkgs-ha": "true", diff --git a/pkg/csi/service/common/commonco/k8sorchestrator/k8sorchestrator.go b/pkg/csi/service/common/commonco/k8sorchestrator/k8sorchestrator.go index 734e7d1e7b..ae22d26984 100644 --- a/pkg/csi/service/common/commonco/k8sorchestrator/k8sorchestrator.go +++ b/pkg/csi/service/common/commonco/k8sorchestrator/k8sorchestrator.go @@ -389,7 +389,6 @@ func Newk8sOrchestrator(ctx context.Context, controllerClusterFlavor cnstypes.Cn func getReleasedVanillaFSS() map[string]struct{} { return map[string]struct{}{ - common.CSIMigration: {}, common.OnlineVolumeExtend: {}, common.BlockVolumeSnapshot: {}, common.CSIWindowsSupport: {}, @@ -999,7 +998,6 @@ func pvAdded(obj interface{}) { // Since cns query will return all the volumes including the migrated ones, the map would need to be a // union of migrated VCP-CSI volumes and CSI volumes, as well. if pv.Spec.VsphereVolume != nil && - k8sOrchestratorInstance.IsFSSEnabled(context.Background(), common.CSIMigration) && isValidMigratedvSphereVolume(context.Background(), pv.ObjectMeta) { if pv.Status.Phase == v1.VolumeBound { k8sOrchestratorInstance.volumeIDToNameMap.add(pv.Spec.VsphereVolume.VolumePath, pv.Name) @@ -1049,7 +1047,6 @@ func pvUpdated(oldObj, newObj interface{}) { // Since cns query will return all the volumes including the migrated ones, the map would need to be a // union of migrated VCP-CSI volumes and CSI volumes, as well. if newPv.Spec.VsphereVolume != nil && - k8sOrchestratorInstance.IsFSSEnabled(context.Background(), common.CSIMigration) && isValidMigratedvSphereVolume(context.Background(), newPv.ObjectMeta) { if oldPv.Status.Phase != v1.VolumeBound && newPv.Status.Phase == v1.VolumeBound { k8sOrchestratorInstance.volumeIDToNameMap.add(newPv.Spec.VsphereVolume.VolumePath, newPv.Name) @@ -1078,7 +1075,7 @@ func pvDeleted(obj interface{}) { log.Debugf("k8sorchestrator: Deleted key %s from pvcToVolumeID", pv.Spec.ClaimRef.Namespace+"/"+pv.Spec.ClaimRef.Name) } - if pv.Spec.VsphereVolume != nil && k8sOrchestratorInstance.IsFSSEnabled(context.Background(), common.CSIMigration) { + if pv.Spec.VsphereVolume != nil { k8sOrchestratorInstance.volumeIDToNameMap.remove(pv.Spec.VsphereVolume.VolumePath) log.Debugf("k8sorchestrator migrated volume: Deleted key %s from volumeIDToNameMap", pv.Spec.VsphereVolume.VolumePath) diff --git a/pkg/csi/service/common/constants.go b/pkg/csi/service/common/constants.go index cf4c266b85..d46ffea949 100644 --- a/pkg/csi/service/common/constants.go +++ b/pkg/csi/service/common/constants.go @@ -379,8 +379,6 @@ const ( DefaultFeatureEnablementCheckInterval = 1 * time.Minute // OnlineVolumeExtend guards the feature for online volume expansion. OnlineVolumeExtend = "online-volume-extend" - // CSIMigration is feature flag for migrating in-tree vSphere volumes to CSI. - CSIMigration = "csi-migration" // CSISVFeatureStateReplication is feature flag for SV feature state // replication feature. CSISVFeatureStateReplication = "csi-sv-feature-states-replication" diff --git a/pkg/csi/service/common/util.go b/pkg/csi/service/common/util.go index 7faf1b8881..93ed9c1fda 100644 --- a/pkg/csi/service/common/util.go +++ b/pkg/csi/service/common/util.go @@ -240,64 +240,48 @@ func IsValidVolumeCapabilities(ctx context.Context, volCaps []*csi.VolumeCapabil // ParseStorageClassParams parses the params in the CSI CreateVolumeRequest API // call back to StorageClassParams structure. -func ParseStorageClassParams(ctx context.Context, params map[string]string, - csiMigrationFeatureState bool) (*StorageClassParams, error) { +func ParseStorageClassParams(ctx context.Context, params map[string]string) (*StorageClassParams, error) { log := logger.GetLogger(ctx) scParams := &StorageClassParams{ DatastoreURL: "", StoragePolicyName: "", } - if !csiMigrationFeatureState { - for param, value := range params { - param = strings.ToLower(param) - if param == AttributeDatastoreURL { - scParams.DatastoreURL = value - } else if param == AttributeStoragePolicyName { - scParams.StoragePolicyName = value - } else if param == AttributeFsType { - log.Warnf("param 'fstype' is deprecated, please use 'csi.storage.k8s.io/fstype' instead") - } else { - return nil, fmt.Errorf("invalid param: %q and value: %q", param, value) - } + otherParams := make(map[string]string) + for param, value := range params { + param = strings.ToLower(param) + if param == AttributeDatastoreURL { + scParams.DatastoreURL = value + } else if param == AttributeStoragePolicyName { + scParams.StoragePolicyName = value + } else if param == AttributeFsType { + log.Warnf("param 'fstype' is deprecated, please use 'csi.storage.k8s.io/fstype' instead") + } else if param == CSIMigrationParams { + scParams.CSIMigration = value + } else { + otherParams[param] = value } - } else { - otherParams := make(map[string]string) - for param, value := range params { + } + // check otherParams belongs to in-tree migrated Parameters. + if scParams.CSIMigration == "true" { + for param, value := range otherParams { param = strings.ToLower(param) - if param == AttributeDatastoreURL { - scParams.DatastoreURL = value - } else if param == AttributeStoragePolicyName { - scParams.StoragePolicyName = value - } else if param == AttributeFsType { - log.Warnf("param 'fstype' is deprecated, please use 'csi.storage.k8s.io/fstype' instead") - } else if param == CSIMigrationParams { - scParams.CSIMigration = value + if param == DatastoreMigrationParam { + scParams.Datastore = value + } else if param == DiskFormatMigrationParam && value == "thin" { + continue + } else if param == HostFailuresToTolerateMigrationParam || + param == ForceProvisioningMigrationParam || param == CacheReservationMigrationParam || + param == DiskstripesMigrationParam || param == ObjectspacereservationMigrationParam || + param == IopslimitMigrationParam { + return nil, fmt.Errorf("vSphere CSI driver does not support creating volume using "+ + "in-tree vSphere volume plugin parameter key:%v, value:%v", param, value) } else { - otherParams[param] = value + return nil, fmt.Errorf("invalid parameter. key:%v, value:%v", param, value) } } - // check otherParams belongs to in-tree migrated Parameters. - if scParams.CSIMigration == "true" { - for param, value := range otherParams { - param = strings.ToLower(param) - if param == DatastoreMigrationParam { - scParams.Datastore = value - } else if param == DiskFormatMigrationParam && value == "thin" { - continue - } else if param == HostFailuresToTolerateMigrationParam || - param == ForceProvisioningMigrationParam || param == CacheReservationMigrationParam || - param == DiskstripesMigrationParam || param == ObjectspacereservationMigrationParam || - param == IopslimitMigrationParam { - return nil, fmt.Errorf("vSphere CSI driver does not support creating volume using "+ - "in-tree vSphere volume plugin parameter key:%v, value:%v", param, value) - } else { - return nil, fmt.Errorf("invalid parameter. key:%v, value:%v", param, value) - } - } - } else { - if len(otherParams) != 0 { - return nil, fmt.Errorf("invalid parameters :%v", otherParams) - } + } else { + if len(otherParams) != 0 { + return nil, fmt.Errorf("invalid parameters :%v", otherParams) } } return scParams, nil diff --git a/pkg/csi/service/common/util_test.go b/pkg/csi/service/common/util_test.go index ace87bdbdc..1ca1a236aa 100644 --- a/pkg/csi/service/common/util_test.go +++ b/pkg/csi/service/common/util_test.go @@ -377,42 +377,7 @@ func isStorageClassParamsEqual(expected *StorageClassParams, actual *StorageClas return true } -func TestParseStorageClassParamsWithDeprecatedFSType(t *testing.T) { - params := map[string]string{ - "fstype": "ext4", - } - expectedScParams := &StorageClassParams{} - csiMigrationFeatureState := false - actualScParams, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) - if err != nil { - t.Errorf("failed to parse params: %+v", params) - } - if !isStorageClassParamsEqual(expectedScParams, actualScParams) { - t.Errorf("Expected: %+v\n Actual: %+v", expectedScParams, actualScParams) - } -} - -func TestParseStorageClassParamsWithValidParams(t *testing.T) { - params := map[string]string{ - AttributeDatastoreURL: "ds1", - AttributeStoragePolicyName: "policy1", - } - expectedScParams := &StorageClassParams{ - DatastoreURL: "ds1", - StoragePolicyName: "policy1", - } - csiMigrationFeatureState := false - actualScParams, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) - if err != nil { - t.Errorf("failed to parse params: %+v", params) - } - if !isStorageClassParamsEqual(expectedScParams, actualScParams) { - t.Errorf("Expected: %+v\n Actual: %+v", expectedScParams, actualScParams) - } -} - func TestParseStorageClassParamsWithMigrationEnabledNagative(t *testing.T) { - csiMigrationFeatureState := true params := map[string]string{ CSIMigrationParams: "true", DatastoreMigrationParam: "vSANDatastore", @@ -424,7 +389,7 @@ func TestParseStorageClassParamsWithMigrationEnabledNagative(t *testing.T) { ObjectspacereservationMigrationParam: "50", IopslimitMigrationParam: "16", } - scParam, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) + scParam, err := ParseStorageClassParams(ctx, params) if err == nil { t.Errorf("error expected but not received. scParam received from ParseStorageClassParams: %v", scParam) } @@ -432,12 +397,11 @@ func TestParseStorageClassParamsWithMigrationEnabledNagative(t *testing.T) { } func TestParseStorageClassParamsWithDiskFormatMigrationEnableNegative(t *testing.T) { - csiMigrationFeatureState := true params := map[string]string{ CSIMigrationParams: "true", DiskFormatMigrationParam: "thick", } - scParam, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) + scParam, err := ParseStorageClassParams(ctx, params) if err == nil { t.Errorf("error expected but not received. scParam received from ParseStorageClassParams: %v", scParam) } @@ -445,7 +409,6 @@ func TestParseStorageClassParamsWithDiskFormatMigrationEnableNegative(t *testing } func TestParseStorageClassParamsWithDiskFormatMigrationEnablePositive(t *testing.T) { - csiMigrationFeatureState := true params := map[string]string{ CSIMigrationParams: "true", DiskFormatMigrationParam: "thin", @@ -453,7 +416,7 @@ func TestParseStorageClassParamsWithDiskFormatMigrationEnablePositive(t *testing expectedScParams := &StorageClassParams{ CSIMigration: "true", } - scParam, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) + scParam, err := ParseStorageClassParams(ctx, params) if err != nil { t.Errorf("failed to parse params: %+v, err: %+v", params, err) } @@ -463,7 +426,6 @@ func TestParseStorageClassParamsWithDiskFormatMigrationEnablePositive(t *testing } func TestParseStorageClassParamsWithMigrationEnabledPositive(t *testing.T) { - csiMigrationFeatureState := true params := map[string]string{ CSIMigrationParams: "true", DatastoreMigrationParam: "vSANDatastore", @@ -474,7 +436,7 @@ func TestParseStorageClassParamsWithMigrationEnabledPositive(t *testing.T) { StoragePolicyName: "policy1", CSIMigration: "true", } - scParam, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) + scParam, err := ParseStorageClassParams(ctx, params) if err != nil { t.Errorf("failed to parse params: %+v", params) } @@ -483,21 +445,6 @@ func TestParseStorageClassParamsWithMigrationEnabledPositive(t *testing.T) { } } -func TestParseStorageClassParamsWithMigrationDisabled(t *testing.T) { - csiMigrationFeatureState := false - params := map[string]string{ - CSIMigrationParams: "true", - DatastoreMigrationParam: "vSANDatastore", - AttributeStoragePolicyName: "policy1", - HostFailuresToTolerateMigrationParam: "1", - } - scParam, err := ParseStorageClassParams(ctx, params, csiMigrationFeatureState) - if err == nil { - t.Errorf("error expected but not received. scParam received from ParseStorageClassParams: %v", scParam) - } - t.Logf("expected err received. err: %v", err) -} - func TestParseCSISnapshotID(t *testing.T) { type args struct { ctx context.Context diff --git a/pkg/csi/service/vanilla/controller.go b/pkg/csi/service/vanilla/controller.go index 191fae303b..ccc016df8d 100644 --- a/pkg/csi/service/vanilla/controller.go +++ b/pkg/csi/service/vanilla/controller.go @@ -89,9 +89,9 @@ var ( // This will hold mapping for VolumeID to vCenter for multi vCenter CSI topology deployment volumeInfoService cnsvolumeinfo.VolumeInfoService - // The following variables hold feature states for multi-vcenter-csi-topology, CSI Migration + // The following variables hold feature states for multi-vcenter-csi-topology // and authorisation check. - multivCenterCSITopologyEnabled, csiMigrationEnabled, filterSuspendedDatastores, + multivCenterCSITopologyEnabled, filterSuspendedDatastores, isTopologyAwareFileVolumeEnabled, isCSITransactionSupportEnabled bool // variables for list volumes @@ -131,7 +131,6 @@ func (c *controller) Init(config *cnsconfig.Config, version string) error { // Check if the feature states are enabled. multivCenterCSITopologyEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.MultiVCenterCSITopology) - csiMigrationEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) filterSuspendedDatastores = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CnsMgrSuspendCreateVolume) isTopologyAwareFileVolumeEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, @@ -329,26 +328,24 @@ func (c *controller) Init(config *cnsconfig.Config, version string) error { log.Errorf("failed to watch on path: %q. err=%v", cfgDirPath, err) return err } - if commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) { - if !multivCenterCSITopologyEnabled { - log.Info("CSI Migration Feature is Enabled. Loading Volume Migration Service") - volumeMigrationService, err = migration.GetVolumeMigrationService(ctx, &c.manager.VolumeManager, config, false) + if !multivCenterCSITopologyEnabled { + log.Info("Loading Volume Migration Service") + volumeMigrationService, err = migration.GetVolumeMigrationService(ctx, &c.manager.VolumeManager, config, false) + if err != nil { + log.Errorf("failed to get migration service. Err: %v", err) + return err + } + } else { + if len(c.managers.VcenterConfigs) == 1 { + log.Info("Loading Volume Migration Service") + volumeManager := c.managers.VolumeManagers[c.managers.CnsConfig.Global.VCenterIP] + volumeMigrationService, err = migration.GetVolumeMigrationService(ctx, &volumeManager, config, false) if err != nil { log.Errorf("failed to get migration service. Err: %v", err) return err } } else { - if len(c.managers.VcenterConfigs) == 1 { - log.Info("CSI Migration Feature is Enabled. Loading Volume Migration Service") - volumeManager := c.managers.VolumeManagers[c.managers.CnsConfig.Global.VCenterIP] - volumeMigrationService, err = migration.GetVolumeMigrationService(ctx, &volumeManager, config, false) - if err != nil { - log.Errorf("failed to get migration service. Err: %v", err) - return err - } - } else { - log.Infof("vSphere CSI Migration is not supported on the multi vCenter setup") - } + log.Infof("vSphere CSI Migration is not supported on the multi vCenter setup") } } @@ -524,7 +521,6 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum // Check if the feature states are enabled. isBlockVolumeSnapshotEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) - csiMigrationFeatureState := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) // Check if requested volume size and source snapshot size matches volumeSource := req.GetVolumeContentSource() @@ -572,9 +568,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum volSizeBytes, snapshotSizeInBytes) } } - // Fetching the feature state for csi-migration before parsing storage class - // params. - scParams, err := common.ParseStorageClassParams(ctx, req.Parameters, csiMigrationFeatureState) + scParams, err := common.ParseStorageClassParams(ctx, req.Parameters) // TODO: Need to figure out the fault returned by ParseStorageClassParams. // Currently, just return "csi.fault.Internal". if err != nil { @@ -582,7 +576,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum "parsing storage class parameters failed with error: %+v", err) } - if csiMigrationFeatureState && scParams.CSIMigration == "true" { + if scParams.CSIMigration == "true" { if len(scParams.Datastore) != 0 { log.Infof("Converting datastore name: %q to Datastore URL", scParams.Datastore) // Get vCenter. @@ -794,7 +788,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum attributes := make(map[string]string) attributes[common.AttributeDiskType] = common.DiskTypeBlockVolume - if csiMigrationFeatureState && scParams.CSIMigration == "true" { + if scParams.CSIMigration == "true" { // In case if feature state switch is enabled after controller is // deployed, we need to initialize the volumeMigrationService. if err := initVolumeMigrationService(ctx, c); err != nil { @@ -953,7 +947,7 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context. } volSizeMB := int64(common.RoundUpSize(volSizeBytes, common.MbInBytes)) - scParams, err := common.ParseStorageClassParams(ctx, req.Parameters, csiMigrationEnabled) + scParams, err := common.ParseStorageClassParams(ctx, req.Parameters) // TODO: Need to figure out the fault returned by ParseStorageClassParams. // Currently, just return "csi.fault.Internal". if err != nil { @@ -1641,11 +1635,7 @@ func (c *controller) createFileVolume(ctx context.Context, req *csi.CreateVolume volSizeBytes = int64(req.GetCapacityRange().GetRequiredBytes()) } volSizeMB := int64(common.RoundUpSize(volSizeBytes, common.MbInBytes)) - - // Fetching the feature state for csi-migration before parsing storage class - // params. - csiMigrationFeatureState := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) - scParams, err := common.ParseStorageClassParams(ctx, req.Parameters, csiMigrationFeatureState) + scParams, err := common.ParseStorageClassParams(ctx, req.Parameters) // TODO: Need to figure out the fault returned by ParseStorageClassParams. // Currently, just return "csi.fault.Internal". if err != nil { @@ -2132,12 +2122,6 @@ func (c *controller) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequ volumeType = prometheus.PrometheusBlockVolumeType cnsVolumeType = common.BlockVolumeType // In-tree volume support. - if !commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) { - // Migration feature switch is disabled. - return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal, - "volume-migration feature switch is disabled. Cannot use volume with vmdk path :%q", req.VolumeId) - } - // Migration feature switch is enabled. volumePath = req.VolumeId // In case if feature state switch is enabled after controller is // deployed, we need to initialize the volumeMigrationService. @@ -2314,12 +2298,6 @@ func (c *controller) ControllerPublishVolume(ctx context.Context, req *csi.Contr volumeType = prometheus.PrometheusBlockVolumeType if strings.Contains(req.VolumeId, ".vmdk") { // In-tree volume support. - if !commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) { - // Migration feature switch is disabled. - return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal, - "volume-migration feature switch is disabled. Cannot use volume with vmdk path :%q", req.VolumeId) - } - // Migration feature switch is enabled. storagePolicyName := req.VolumeContext[common.AttributeStoragePolicyName] volumePath := req.VolumeId // In case if feature state switch is enabled after controller is @@ -2449,13 +2427,7 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con } else { // In-tree volume support. volumeType = prometheus.PrometheusBlockVolumeType - if !commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) { - // Migration feature switch is disabled. - return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal, - "volume-migration feature switch is disabled. Cannot use volume with vmdk path: %q", req.VolumeId) - } - // Migration feature switch is enabled. - // + // ControllerUnpublishVolume will never be the first call back for vmdk // registration with CNS. Here in the migration.VolumeSpec, we do not // supply SPBM Policy name. Node drain is the pre-requisite for volume diff --git a/pkg/syncer/admissionhandler/admissionhandler.go b/pkg/syncer/admissionhandler/admissionhandler.go index f885955a89..d9c4030a8f 100644 --- a/pkg/syncer/admissionhandler/admissionhandler.go +++ b/pkg/syncer/admissionhandler/admissionhandler.go @@ -55,7 +55,6 @@ var ( // 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 featureGateTopologyAwareFileVolumeEnabled bool @@ -169,14 +168,13 @@ func StartWebhookServer(ctx context.Context, enableWebhookClientCertVerification } log.Debugf("webhook config: %v", cfg) } - featureGateCsiMigrationEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) featureGateBlockVolumeSnapshotEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.BlockVolumeSnapshot) featureGateTopologyAwareFileVolumeEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.TopologyAwareFileVolume) featureFileVolumesWithVmServiceEnabled = containerOrchestratorUtility.IsFSSEnabled(ctx, common.FileVolumesWithVmService) - if featureGateCsiMigrationEnabled || featureGateBlockVolumeSnapshotEnabled { + if featureGateBlockVolumeSnapshotEnabled { certs, err := tls.LoadX509KeyPair(cfg.WebHookConfig.CertFile, cfg.WebHookConfig.KeyFile) if err != nil { log.Errorf("failed to load key pair. certFile: %q, keyFile: %q err: %v", diff --git a/pkg/syncer/admissionhandler/validatestorageclass.go b/pkg/syncer/admissionhandler/validatestorageclass.go index 03d87b3e19..833c87b9f0 100644 --- a/pkg/syncer/admissionhandler/validatestorageclass.go +++ b/pkg/syncer/admissionhandler/validatestorageclass.go @@ -49,13 +49,6 @@ const ( // validateStorageClass helps validate AdmissionReview requests for StroageClass. func validateStorageClass(ctx context.Context, ar *admissionv1.AdmissionReview) *admissionv1.AdmissionResponse { - if !featureGateCsiMigrationEnabled { - // If CSI migration is disabled and webhook is running, - // skip validation for StorageClass. - return &admissionv1.AdmissionResponse{ - Allowed: true, - } - } log := logger.GetLogger(ctx) req := ar.Request var result *metav1.Status diff --git a/pkg/syncer/admissionhandler/validatestorageclass_test.go b/pkg/syncer/admissionhandler/validatestorageclass_test.go index f71da2183a..7c33d945fc 100644 --- a/pkg/syncer/admissionhandler/validatestorageclass_test.go +++ b/pkg/syncer/admissionhandler/validatestorageclass_test.go @@ -40,7 +40,6 @@ var admissionReview = v1.AdmissionReview{ func TestValidateStorageClassForAllowVolumeExpansion(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - featureGateCsiMigrationEnabled = true admissionReview.Request.Object = runtime.RawExtension{ Raw: []byte("{\n \"kind\": \"StorageClass\",\n \"apiVersion\": \"storage.k8s.io/v1\",\n \"metadata\": " + "{\n \"name\": \"sc\",\n \"uid\": \"e5d6b37e-db23-4c1d-9aed-e38cdd0f9ec6\",\n " + @@ -65,7 +64,6 @@ func TestValidateStorageClassForAllowVolumeExpansion(t *testing.T) { func TestValidateStorageClassForMigrationParameter(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - featureGateCsiMigrationEnabled = true admissionReview.Request.Object = runtime.RawExtension{ Raw: []byte("{\n \"kind\": \"StorageClass\",\n \"apiVersion\": \"storage.k8s.io/v1\",\n \"metadata\": " + "{\n \"name\": \"sc\",\n \"uid\": \"a9ed134e-aab1-4624-8de4-b9d961cad861\",\n " + @@ -103,7 +101,6 @@ func TestValidateStorageClassForMigrationParameter(t *testing.T) { func TestValidateStorageClassForValidStorageClass(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - featureGateCsiMigrationEnabled = true admissionReview.Request.Object = runtime.RawExtension{ Raw: []byte("{\n \"kind\": \"StorageClass\",\n \"apiVersion\": \"storage.k8s.io/v1\",\n \"metadata\": " + "{\n \"name\": \"sc\",\n \"uid\": \"a896f427-929a-4fc5-be95-078d99d57774\",\n " + diff --git a/pkg/syncer/fullsync.go b/pkg/syncer/fullsync.go index 3ecc3750fc..1ab5785e25 100644 --- a/pkg/syncer/fullsync.go +++ b/pkg/syncer/fullsync.go @@ -76,8 +76,7 @@ func CsiFullSync(ctx context.Context, metadataSyncer *metadataSyncInformer, vc s var err error // Fetch CSI migration feature state, before performing full sync operations. if metadataSyncer.clusterFlavor == cnstypes.CnsClusterFlavorVanilla { - if metadataSyncer.coCommonInterface.IsFSSEnabled(ctx, common.CSIMigration) && - len(metadataSyncer.configInfo.Cfg.VirtualCenter) == 1 { + if len(metadataSyncer.configInfo.Cfg.VirtualCenter) == 1 { migrationFeatureStateForFullSync = true } } diff --git a/pkg/syncer/metadatasyncer.go b/pkg/syncer/metadatasyncer.go index 161f5a71e6..94b536de8b 100644 --- a/pkg/syncer/metadatasyncer.go +++ b/pkg/syncer/metadatasyncer.go @@ -104,8 +104,6 @@ var ( // isSharedDiskEabled is true if shared disks are supported on the supervisor cluster isSharedDiskEabled bool - //IsMigrationEnabled is true when in-tree to CSI Migration FSS is enabled for the driver, false otherwise. - IsMigrationEnabled bool // nodeMgr stores the manager to interact with nodeVMs. nodeMgr node.Manager // IsPodVMOnStretchSupervisorFSSEnabled is true when PodVMOnStretchedSupervisor FSS is enabled. @@ -230,7 +228,6 @@ func InitMetadataSyncer(ctx context.Context, clusterFlavor cnstypes.CnsClusterFl if clusterFlavor == cnstypes.CnsClusterFlavorVanilla { isMultiVCenterFssEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.MultiVCenterCSITopology) - IsMigrationEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSIMigration) } isStorageQuotaM2FSSEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.StorageQuotaM2) // Create the kubernetes client from config. @@ -2268,7 +2265,7 @@ func pvcUpdated(oldObj, newObj interface{}, metadataSyncer *metadataSyncInformer // Verify if csi migration is ON and check if there is any label update or // migrated-to annotation was received for the PVC. - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // If it is a multi VC setup, then skip this volume as we do not support vSphere to CSI migrated volumes // on a multi VC deployment. if isMultiVCenterFssEnabled && len(metadataSyncer.configInfo.Cfg.VirtualCenter) > 1 { @@ -2306,11 +2303,6 @@ func pvcUpdated(oldObj, newObj interface{}, metadataSyncer *metadataSyncInformer } } } else { - if pv.Spec.VsphereVolume != nil { - // Volume is in-tree VCP volume. - log.Warnf("PVCUpdated: %q feature state is disabled. Skipping the PVC update", common.CSIMigration) - return - } // Verify if pv is vsphere csi volume. if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != csitypes.Name { log.Debugf("PVCUpdated: Not a vSphere CSI Volume") @@ -2352,7 +2344,7 @@ func pvcDeleted(obj interface{}, metadataSyncer *metadataSyncInformer) { return } - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // If it is a multi VC setup, then skip this volume as we do not support vSphere to CSI migrated volumes // on a multi VC deployment. if isMultiVCenterFssEnabled && len(metadataSyncer.configInfo.Cfg.VirtualCenter) > 1 { @@ -2370,11 +2362,6 @@ func pvcDeleted(obj interface{}, metadataSyncer *metadataSyncInformer) { } } } else { - if pv.Spec.VsphereVolume != nil { - // Volume is in-tree VCP volume. - log.Warnf("PVCDeleted: %q feature state is disabled. Skipping the PVC delete", common.CSIMigration) - return - } // Verify if pv is vSphere csi volume. if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != csitypes.Name { log.Debugf("PVCDeleted: Not a vSphere CSI Volume") @@ -2448,7 +2435,7 @@ func pvUpdated(oldObj, newObj interface{}, metadataSyncer *metadataSyncInformer) newPv.Name, newPv.Status.Phase) return } - if IsMigrationEnabled && newPv.Spec.VsphereVolume != nil { + if newPv.Spec.VsphereVolume != nil { // If it is a multi VC setup, then skip this volume as we do not support vSphere to CSI migrated volumes // on a multi VC deployment. @@ -2483,11 +2470,6 @@ func pvUpdated(oldObj, newObj interface{}, metadataSyncer *metadataSyncInformer) } } } else { - if newPv.Spec.VsphereVolume != nil { - // Volume is in-tree VCP volume. - log.Warnf("PVUpdated: %q feature state is disabled. Skipping the PV update", common.CSIMigration) - return - } // Verify if pv is a vSphere csi volume. if newPv.Spec.CSI == nil || newPv.Spec.CSI.Driver != csitypes.Name { log.Debugf("PVUpdated: PV is not a vSphere CSI Volume: %+v", newPv) @@ -2528,7 +2510,7 @@ func pvDeleted(obj interface{}, metadataSyncer *metadataSyncInformer) { } log.Debugf("PVDeleted: PV: %+v", pv) - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // If it is a multi VC setup, then skip this volume as we do not support vSphere to CSI migrated volumes // on a multi VC deployment. @@ -2544,11 +2526,6 @@ func pvDeleted(obj interface{}, metadataSyncer *metadataSyncInformer) { return } } else { - if pv.Spec.VsphereVolume != nil { - // Volume is in-tree VCP volume. - log.Warnf("PVDeleted: %q feature state is disabled. Skipping the PVC update", common.CSIMigration) - return - } // Verify if pv is a vSphere csi volume. if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != csitypes.Name { log.Debugf("PVDeleted: Not a vSphere CSI Volume. PV: %+v", pv) @@ -2567,7 +2544,7 @@ func pvDeleted(obj interface{}, metadataSyncer *metadataSyncInformer) { // NOTE: This functionality will be skipped if it is called in a multi-VC environment. func podAdded(obj interface{}, metadataSyncer *metadataSyncInformer) { ctx, log := logger.GetNewContextWithLogger() - if metadataSyncer.clusterFlavor == cnstypes.CnsClusterFlavorVanilla && IsMigrationEnabled { + if metadataSyncer.clusterFlavor == cnstypes.CnsClusterFlavorVanilla { // Get pod object. pod, ok := obj.(*v1.Pod) if pod == nil || !ok { @@ -2697,7 +2674,7 @@ func csiPVCUpdated(ctx context.Context, pvc *v1.PersistentVolumeClaim, vcHost string cnsVolumeMgr volumes.Manager ) - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // In case if feature state switch is enabled after syncer is deployed, // we need to initialize the volumeMigrationService. if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { @@ -2820,7 +2797,7 @@ func csiPVCDeleted(ctx context.Context, pvc *v1.PersistentVolumeClaim, var volumeHandle string var err error - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // In case if feature state switch is enabled after syncer is deployed, // we need to initialize the volumeMigrationService. if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { @@ -2890,7 +2867,7 @@ func csiPVUpdated(ctx context.Context, newPv *v1.PersistentVolume, oldPv *v1.Per vcHost string isTopologyAwareFileVolumeEnabled bool ) - if IsMigrationEnabled && newPv.Spec.VsphereVolume != nil { + if newPv.Spec.VsphereVolume != nil { // In case if feature state switch is enabled after syncer is deployed, // we need to initialize the volumeMigrationService. if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { @@ -3252,7 +3229,7 @@ func csiPVDeleted(ctx context.Context, pv *v1.PersistentVolume, metadataSyncer * ) // Fetch FSS value for CSI migration once. - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // In case if feature state switch is enabled after syncer is deployed, // we need to initialize the volumeMigrationService. if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { @@ -3286,7 +3263,7 @@ func csiPVDeleted(ctx context.Context, pv *v1.PersistentVolume, metadataSyncer * if _, err := cnsVolumeMgr.DeleteVolume(ctx, volumeHandle, false); err != nil { log.Errorf("PVDeleted: Failed to delete disk %s with error %+v", volumeHandle, err) } - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // Delete the cnsvspherevolumemigration crd instance when PV is deleted. err = volumeMigrationService.DeleteVolumeInfo(ctx, volumeHandle) if err != nil { @@ -3347,7 +3324,7 @@ func csiUpdatePod(ctx context.Context, pod *v1.Pod, metadataSyncer *metadataSync clusterIDforVolumeMetadata, nil) } metadataList = append(metadataList, cnstypes.BaseCnsEntityMetadata(podMetadata)) - if IsMigrationEnabled && pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { // In case if feature state switch is enabled after syncer is // deployed, we need to initialize the volumeMigrationService. if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { @@ -3376,41 +3353,28 @@ func csiUpdatePod(ctx context.Context, pod *v1.Pod, metadataSyncer *metadataSync } } else { // Inline migrated volumes with no PVC. - if IsMigrationEnabled { - if volume.VsphereVolume != nil { - // No entity reference is supplied for inline volumes. - podMetadata = cnsvsphere.GetCnsKubernetesEntityMetaData(pod.Name, nil, deleteFlag, - string(cnstypes.CnsKubernetesEntityTypePOD), pod.Namespace, - clusterIDforVolumeMetadata, nil) - metadataList = append(metadataList, cnstypes.BaseCnsEntityMetadata(podMetadata)) - var err error - // In case if feature state switch is enabled after syncer is - // deployed, we need to initialize the volumeMigrationService. - if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { - log.Errorf("PodUpdated: Failed to get migration service. Err: %v", err) - return - } - migrationVolumeSpec := &migration.VolumeSpec{VolumePath: volume.VsphereVolume.VolumePath} - volumeHandle, err = volumeMigrationService.GetVolumeID(ctx, migrationVolumeSpec, true) - if err != nil { - log.Warnf("Failed to get VolumeID from volumeMigrationService for migration VolumeSpec: %v "+ - "with error %+v", migrationVolumeSpec, err) - return - } - } else { - log.Debugf("Volume %q is not an inline migrated vSphere volume", volume.Name) - continue + if volume.VsphereVolume != nil { + // No entity reference is supplied for inline volumes. + podMetadata = cnsvsphere.GetCnsKubernetesEntityMetaData(pod.Name, nil, deleteFlag, + string(cnstypes.CnsKubernetesEntityTypePOD), pod.Namespace, + clusterIDforVolumeMetadata, nil) + metadataList = append(metadataList, cnstypes.BaseCnsEntityMetadata(podMetadata)) + var err error + // In case if feature state switch is enabled after syncer is + // deployed, we need to initialize the volumeMigrationService. + if err = initVolumeMigrationService(ctx, metadataSyncer); err != nil { + log.Errorf("PodUpdated: Failed to get migration service. Err: %v", err) + return } - } else { - // For vSphere volumes we need to log the message that CSI - // migration feature state is disabled. - if volume.VsphereVolume != nil { - log.Debug("CSI migration feature state is disabled") - continue + migrationVolumeSpec := &migration.VolumeSpec{VolumePath: volume.VsphereVolume.VolumePath} + volumeHandle, err = volumeMigrationService.GetVolumeID(ctx, migrationVolumeSpec, true) + if err != nil { + log.Warnf("Failed to get VolumeID from volumeMigrationService for migration VolumeSpec: %v "+ + "with error %+v", migrationVolumeSpec, err) + return } - // For non vSphere volumes, do nothing and move to next volume - // iteration. - log.Debugf("Ignoring the update for inline volume %q for the pod %q", volume.Name, pod.Name) + } else { + log.Debugf("Volume %q is not an inline migrated vSphere volume", volume.Name) continue } } diff --git a/pkg/syncer/util.go b/pkg/syncer/util.go index 50fa1a0ae7..d959023953 100644 --- a/pkg/syncer/util.go +++ b/pkg/syncer/util.go @@ -67,8 +67,7 @@ func getPVsInBoundAvailableOrReleased(ctx context.Context, } for _, pv := range allPVs { if (pv.Spec.CSI != nil && pv.Spec.CSI.Driver == csitypes.Name) || - (metadataSyncer.coCommonInterface.IsFSSEnabled(ctx, common.CSIMigration) && pv.Spec.VsphereVolume != nil && - isValidvSphereVolume(ctx, pv)) { + (pv.Spec.VsphereVolume != nil && isValidvSphereVolume(ctx, pv)) { log.Debugf("FullSync: pv %v is in state %v", pv.Name, pv.Status.Phase) if pv.Status.Phase == v1.VolumeBound || pv.Status.Phase == v1.VolumeAvailable || pv.Status.Phase == v1.VolumeReleased { @@ -156,14 +155,7 @@ func IsValidVolume(ctx context.Context, volume v1.Volume, pod *v1.Pod, // Verify volume is a in-tree VCP volume. if pv.Spec.VsphereVolume != nil { // Check if migration feature switch is enabled. - if metadataSyncer.coCommonInterface.IsFSSEnabled(ctx, common.CSIMigration) { - if !isValidvSphereVolume(ctx, pv) { - return false, nil, nil - } - } else { - log.Debugf( - "%s feature switch is disabled. Cannot update vSphere volume metadata %s for the pod %s in namespace %s", - common.CSIMigration, pv.Name, pod.Name, pod.Namespace) + if !isValidvSphereVolume(ctx, pv) { return false, nil, nil } } else { @@ -603,8 +595,7 @@ func getPVsInBoundAvailableOrReleasedForVc(ctx context.Context, metadataSyncer * for _, pv := range allPvs { // Check if the PV is an in-tree volume. if pv.Spec.CSI == nil { - if metadataSyncer.coCommonInterface.IsFSSEnabled(ctx, common.CSIMigration) && - pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { return nil, logger.LogNewErrorf(log, "In-tree volumes are not supported on a multi VC set up."+ "Found in-tree volume %q.", pv.Name) @@ -789,8 +780,7 @@ func createMissingFileVolumeInfoCrs(ctx context.Context, metadataSyncer *metadat fileVolumes := make([]*v1.PersistentVolume, 0) for _, pv := range allPvs { if pv.Spec.CSI == nil { - if metadataSyncer.coCommonInterface.IsFSSEnabled(ctx, common.CSIMigration) && - pv.Spec.VsphereVolume != nil { + if pv.Spec.VsphereVolume != nil { log.Errorf("In-tree volumes are not supported on a multi VC set up."+ "Found in-tree volume %s.", pv.Name) return