Skip to content

Commit 28cf870

Browse files
authored
support for late enablement of supports_multiple_clusters_per_zone capability on supervisor (#3481)
1 parent d8e7737 commit 28cf870

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

pkg/csi/service/wcp/controller.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/utils"
5252
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/common"
5353
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/common/commonco"
54+
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/common/commonco/k8sorchestrator"
5455
commoncotypes "sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/common/commonco/types"
5556
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service/logger"
5657
csitypes "sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/types"
@@ -83,6 +84,8 @@ var (
8384
volumeInfoService cnsvolumeinfo.VolumeInfoService
8485
// isPodVMOnStretchSupervisorFSSEnabled is true when PodVMOnStretchedSupervisor FSS is enabled.
8586
isPodVMOnStretchSupervisorFSSEnabled bool
87+
// IsMultipleClustersPerVsphereZoneFSSEnabled is true when supports_multiple_clusters_per_zone FSS is enabled.
88+
IsMultipleClustersPerVsphereZoneFSSEnabled bool
8689
)
8790

8891
var getCandidateDatastores = cnsvsphere.GetCandidateDatastoresInCluster
@@ -153,7 +156,12 @@ func (c *controller) Init(config *cnsconfig.Config, version string) error {
153156
common.PodVMOnStretchedSupervisor)
154157
idempotencyHandlingEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx,
155158
common.CSIVolumeManagerIdempotency)
156-
if commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.MultipleClustersPerVsphereZone) {
159+
IsMultipleClustersPerVsphereZoneFSSEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx,
160+
common.MultipleClustersPerVsphereZone)
161+
if !IsMultipleClustersPerVsphereZoneFSSEnabled {
162+
go k8sorchestrator.HandleLateEnablementOfCapability(ctx, cnstypes.CnsClusterFlavorWorkload,
163+
common.MultipleClustersPerVsphereZone, "", "")
164+
} else {
157165
err := commonco.ContainerOrchestratorUtility.StartZonesInformer(ctx, nil, metav1.NamespaceAll)
158166
if err != nil {
159167
return logger.LogNewErrorf(log, "failed to start zone informer. Error: %v", err)
@@ -521,8 +529,6 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
521529
filterSuspendedDatastores := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CnsMgrSuspendCreateVolume)
522530
isTKGSHAEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.TKGsHA)
523531
isCSITransactionSupportEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.CSITranSactionSupport)
524-
isMultipleClustersPerVsphereZoneEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx,
525-
common.MultipleClustersPerVsphereZone)
526532

527533
topoSegToDatastoresMap := make(map[string][]*cnsvsphere.DatastoreInfo)
528534
if isTKGSHAEnabled {
@@ -552,7 +558,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
552558
hostnameLabelPresent, zoneLabelPresent = checkTopologyKeysFromAccessibilityReqs(topologyRequirement)
553559
if zoneLabelPresent && hostnameLabelPresent {
554560
if isVdppOnStretchedSVEnabled {
555-
if isMultipleClustersPerVsphereZoneEnabled && c.topologyMgr.ZonesWithMultipleClustersExist(ctx) {
561+
if IsMultipleClustersPerVsphereZoneFSSEnabled && c.topologyMgr.ZonesWithMultipleClustersExist(ctx) {
556562
return nil, csifault.CSIInternalFault, logger.LogNewErrorCode(log, codes.Internal,
557563
"Creating volume with both zone and hostname in topology requirement is not "+
558564
"supported on deployment with multiple vSphere Clusters per zone")
@@ -571,7 +577,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
571577
}
572578
// Initiate TKGs HA workflow when the topology requirement contains zone labels only.
573579
log.Infof("Topology aware environment detected with requirement: %+v", topologyRequirement)
574-
if !isMultipleClustersPerVsphereZoneEnabled {
580+
if !IsMultipleClustersPerVsphereZoneFSSEnabled {
575581
log.Debugf("Calling GetSharedDatastoresInTopology: storageTopologyType: %s, "+
576582
"topologyRequirement %+v, topoSegToDatastoresMap %+v",
577583
storageTopologyType, topologyRequirement, topoSegToDatastoresMap)
@@ -859,7 +865,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
859865
StorageClassName: req.Parameters[common.AttributeStorageClassName],
860866
Namespace: req.Parameters[common.AttributePvcNamespace],
861867
IsPodVMOnStretchSupervisorFSSEnabled: isPodVMOnStretchSupervisorFSSEnabled,
862-
IsMultipleClustersPerVsphereZoneEnabled: isMultipleClustersPerVsphereZoneEnabled,
868+
IsMultipleClustersPerVsphereZoneEnabled: IsMultipleClustersPerVsphereZoneFSSEnabled,
863869
})
864870
if err != nil {
865871
if cnsvolume.IsNotSupportedFaultType(ctx, faultType) {
@@ -873,7 +879,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
873879
StorageClassName: req.Parameters[common.AttributeStorageClassName],
874880
Namespace: req.Parameters[common.AttributePvcNamespace],
875881
IsPodVMOnStretchSupervisorFSSEnabled: isPodVMOnStretchSupervisorFSSEnabled,
876-
IsMultipleClustersPerVsphereZoneEnabled: isMultipleClustersPerVsphereZoneEnabled,
882+
IsMultipleClustersPerVsphereZoneEnabled: IsMultipleClustersPerVsphereZoneFSSEnabled,
877883
})
878884
}
879885
}
@@ -940,7 +946,7 @@ func (c *controller) createBlockVolume(ctx context.Context, req *csi.CreateVolum
940946
}
941947
}
942948
} else if zoneLabelPresent {
943-
if isMultipleClustersPerVsphereZoneEnabled && len(volumeInfo.Clusters) > 0 {
949+
if IsMultipleClustersPerVsphereZoneFSSEnabled && len(volumeInfo.Clusters) > 0 {
944950
// Calculate Volume Accessible Topology from Clusters returned in CreateVolume Response
945951
azClusterMap := c.topologyMgr.GetAZClustersMap(ctx)
946952
resp.Volume.AccessibleTopology = GetAccessibleTopologies(volumeInfo.Clusters, azClusterMap)
@@ -1325,10 +1331,6 @@ func (c *controller) createFileVolume(ctx context.Context, req *csi.CreateVolume
13251331
)
13261332

13271333
linkedCloneSupportEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx, common.LinkedCloneSupport)
1328-
1329-
isMultipleClustersPerVsphereZoneEnabled := commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx,
1330-
common.MultipleClustersPerVsphereZone)
1331-
13321334
topologyRequirement = req.AccessibilityRequirements
13331335
// Volume Size - Default is 10 GiB.
13341336
volSizeBytes := int64(common.DefaultGbDiskSize * common.GbInBytes)
@@ -1397,7 +1399,7 @@ func (c *controller) createFileVolume(ctx context.Context, req *csi.CreateVolume
13971399
return nil, csifault.CSIInternalFault, logger.LogNewErrorCode(log, codes.Internal,
13981400
"topology manager not initialized.")
13991401
}
1400-
if isMultipleClustersPerVsphereZoneEnabled {
1402+
if IsMultipleClustersPerVsphereZoneFSSEnabled {
14011403
log.Infof("MultipleClustersPerVsphereZone capability is enabled. Skipping to find candidate " +
14021404
"datastores for volume provisioning.")
14031405
pvcNamespace := req.Parameters[common.AttributePvcNamespace]
@@ -1509,7 +1511,7 @@ func (c *controller) createFileVolume(ctx context.Context, req *csi.CreateVolume
15091511
StorageClassName: req.Parameters[common.AttributeStorageClassName],
15101512
Namespace: req.Parameters[common.AttributePvcNamespace],
15111513
IsPodVMOnStretchSupervisorFSSEnabled: isPodVMOnStretchSupervisorFSSEnabled,
1512-
IsMultipleClustersPerVsphereZoneEnabled: isMultipleClustersPerVsphereZoneEnabled,
1514+
IsMultipleClustersPerVsphereZoneEnabled: IsMultipleClustersPerVsphereZoneFSSEnabled,
15131515
})
15141516
} else {
15151517
volumeInfo, faultType, err = common.CreateFileVolumeUtil(ctx, cnstypes.CnsClusterFlavorWorkload, vc,
@@ -1540,7 +1542,7 @@ func (c *controller) createFileVolume(ctx context.Context, req *csi.CreateVolume
15401542
// Calculate accessible topology for the provisioned volume in case of topology aware environment.
15411543
if isWorkloadDomainIsolationEnabled {
15421544
if zoneLabelPresent {
1543-
if isMultipleClustersPerVsphereZoneEnabled && len(volumeInfo.Clusters) > 0 {
1545+
if IsMultipleClustersPerVsphereZoneFSSEnabled && len(volumeInfo.Clusters) > 0 {
15441546
// Calculate Volume Accessible Topology from Clusters returned in CreateVolume Response
15451547
azClusterMap := c.topologyMgr.GetAZClustersMap(ctx)
15461548
resp.Volume.AccessibleTopology = GetAccessibleTopologies(volumeInfo.Clusters, azClusterMap)

pkg/syncer/metadatasyncer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ var (
112112
IsPodVMOnStretchSupervisorFSSEnabled bool
113113
// IsLinkedCloneSupportFSSEnabled is true when linked-clone-support FSS is enabled.
114114
IsLinkedCloneSupportFSSEnabled bool
115+
// IsMultipleClustersPerVsphereZoneFSSEnabled is true when supports_multiple_clusters_per_zone FSS is enabled
116+
IsMultipleClustersPerVsphereZoneFSSEnabled bool
115117
// ResourceAPIgroupPVC is an empty string as PVC belongs to the core resource group denoted by `""`.
116118
ResourceAPIgroupPVC = ""
117119

@@ -316,6 +318,12 @@ func InitMetadataSyncer(ctx context.Context, clusterFlavor cnstypes.CnsClusterFl
316318
if !IsLinkedCloneSupportFSSEnabled {
317319
go k8sorchestrator.HandleLateEnablementOfCapability(ctx, clusterFlavor, common.LinkedCloneSupport, "", "")
318320
}
321+
IsMultipleClustersPerVsphereZoneFSSEnabled = commonco.ContainerOrchestratorUtility.IsFSSEnabled(ctx,
322+
common.MultipleClustersPerVsphereZone)
323+
if !IsMultipleClustersPerVsphereZoneFSSEnabled {
324+
go k8sorchestrator.HandleLateEnablementOfCapability(ctx, clusterFlavor,
325+
common.MultipleClustersPerVsphereZone, "", "")
326+
}
319327
}
320328

321329
if metadataSyncer.clusterFlavor == cnstypes.CnsClusterFlavorGuest {

0 commit comments

Comments
 (0)