Skip to content

Commit f3467b5

Browse files
authored
use global transaction support check (#3655)
1 parent 3f7ba81 commit f3467b5

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

pkg/csi/service/vanilla/controller.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
551551
// Check if requested volume size and source snapshot size matches.
552552
volumeSource := req.GetVolumeContentSource()
553553
var contentSourceSnapshotID, snapshotDatastoreURL string
554-
var vCenterWithTransactionSupport bool
555554
if volumeSource != nil {
556555
sourceSnapshot := volumeSource.GetSnapshot()
557556
if sourceSnapshot == nil {
@@ -582,13 +581,6 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
582581
"VC %q does not support snapshot operations", vCenterHost)
583582
}
584583

585-
vCenterWithTransactionSupport, err = c.managers.VcenterManager.IsCnsTransactionSupported(ctx, vCenterHost)
586-
if err != nil {
587-
return nil, csifault.CSIUnimplementedFault, logger.LogNewErrorCodef(log, codes.Internal,
588-
"failed to check if cns transaction APIs are supported on VC %q due to error: %v",
589-
vCenterHost, err)
590-
}
591-
592584
// Query capacity in MB and datastore url for block volume snapshot.
593585
volumeIds := []cnstypes.CnsVolumeId{{Id: cnsVolumeID}}
594586
cnsVolumeDetailsMap, err := utils.QueryVolumeDetailsUtil(ctx, volumeManager, volumeIds)
@@ -650,8 +642,6 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
650642
}
651643
break
652644
}
653-
654-
isTransactionAPIsSupported := vCenterWithTransactionSupport && isCSITransactionSupportEnabled
655645
volumeOperationDetails, err := operationStore.GetRequestDetails(ctx, req.Name)
656646
if err != nil {
657647
if apierrors.IsNotFound(err) {
@@ -661,7 +651,7 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
661651
"error occurred while getting CreateVolume task details for block volume %q. Error: %+v",
662652
req.Name, err)
663653
}
664-
} else if !isTransactionAPIsSupported && volumeOperationDetails.OperationDetails != nil {
654+
} else if !isCSITransactionSupportEnabled && volumeOperationDetails.OperationDetails != nil {
665655
if volumeOperationDetails.OperationDetails.TaskStatus ==
666656
cnsvolumeoperationrequest.TaskInvocationStatusSuccess &&
667657
volumeOperationDetails.VolumeID != "" {
@@ -689,7 +679,7 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
689679
},
690680
}
691681
volTaskAlreadyRegistered = true
692-
} else if !isTransactionAPIsSupported && cnsvolume.IsTaskPending(volumeOperationDetails) {
682+
} else if !isCSITransactionSupportEnabled && cnsvolume.IsTaskPending(volumeOperationDetails) {
693683
// If task is already created in CNS for this volume but task is in progress,
694684
// we need to monitor the task to check if volume creation is complete or not.
695685
log.Infof("Volume with name %s has CreateVolume task %s pending on VC %q.",
@@ -883,7 +873,7 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
883873
ClusterFlavor: cnstypes.CnsClusterFlavorVanilla,
884874
},
885875
common.CreateBlockVolumeOptions{
886-
IsCSITransactionSupportEnabled: isTransactionAPIsSupported,
876+
IsCSITransactionSupportEnabled: isCSITransactionSupportEnabled,
887877
})
888878
if err != nil {
889879
if cnsvolume.IsNotSupportedFaultType(ctx, faultType) {
@@ -968,7 +958,7 @@ func (c *controller) createBlockVolumeWithPlacementEngineForMultiVC(ctx context.
968958
ClusterFlavor: cnstypes.CnsClusterFlavorVanilla,
969959
},
970960
common.CreateBlockVolumeOptions{
971-
IsCSITransactionSupportEnabled: isTransactionAPIsSupported,
961+
IsCSITransactionSupportEnabled: isCSITransactionSupportEnabled,
972962
})
973963
if err != nil {
974964
if cnsvolume.IsNotSupportedFaultType(ctx, faultType) {
@@ -2570,15 +2560,9 @@ func (c *controller) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshot
25702560
// VolumeID and SnapshotID as the input, while corresponding snapshot APIs in upstream CSI require SnapshotID.
25712561
// So, we need to bridge the gap in vSphere CSI driver and return a combined SnapshotID to CSI Snapshotter.
25722562

2573-
vCenterWithTransactionSupport, err := vCenterManager.IsCnsTransactionSupported(ctx, vCenterHost)
2574-
if err != nil {
2575-
return nil, logger.LogNewErrorCodef(log, codes.Internal,
2576-
"failed to check if cns transaction APIs are supported on VC %q due to error: %v",
2577-
vCenterHost, err)
2578-
}
25792563
snapshotID, cnsSnapshotInfo, err := common.CreateSnapshotUtil(ctx, volumeManager,
25802564
volumeID, req.Name, &cnsvolume.CreateSnapshotExtraParams{
2581-
IsCSITransactionSupportEnabled: isCSITransactionSupportEnabled && vCenterWithTransactionSupport,
2565+
IsCSITransactionSupportEnabled: isCSITransactionSupportEnabled,
25822566
})
25832567
if err != nil {
25842568
return nil, logger.LogNewErrorCodef(log, codes.Internal,

0 commit comments

Comments
 (0)