Skip to content

Commit 5178766

Browse files
addressing the review comments
Signed-off-by: shravani <[email protected]>
1 parent 188dd74 commit 5178766

File tree

1 file changed

+80
-75
lines changed

1 file changed

+80
-75
lines changed

driver/csiplugin/controllerserver.go

Lines changed: 80 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ type ScaleControllerServer struct {
7373

7474
func (cs *ScaleControllerServer) IfSameVolReqInProcess(scVol *scaleVolume) (bool, error) {
7575
capacity, volpresent := cs.Driver.reqmap[scVol.VolName]
76+
7677
if volpresent {
7778
/* #nosec G115 -- false positive */
78-
if capacity == int64(scVol.VolSize) {
79+
if int64(scVol.VolSize) == capacity {
7980
return true, nil
8081
} else {
8182
return false, status.Error(codes.Internal, fmt.Sprintf("Volume %v present in map but requested size %v does not match with size %v in map", scVol.VolName, scVol.VolSize, capacity))
@@ -269,6 +270,7 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
269270
}
270271

271272
filesetQuotaBytes, err := ConvertToBytes(quota)
273+
272274
if err != nil {
273275
if strings.Contains(err.Error(), "invalid number specified") {
274276
// Invalid number specified means quota is not set
@@ -279,16 +281,16 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
279281
}
280282

281283
// changing volsize here for pvc size in decimal units to align with scale block size
282-
filesystemname := scVol.VolBackendFs
283-
klog.Info("Filesystemname", filesystemname)
284-
filesystemdetails, err := cs.Driver.connmap["primary"].GetFilesystemDetails(ctx, filesystemname)
285-
if err != nil {
286-
klog.Errorf("Unable to get the filesystemdetails")
287-
}
288-
klog.Info("filesystem details", filesystemdetails)
289-
blockinfo := filesystemdetails.Block.BlockSize
290-
roundedblock := uint64(math.Floor(float64(scVol.VolSize) / float64(blockinfo)))
291-
scVol.VolSize = roundedblock * uint64(blockinfo)
284+
// filesystemName := scVol.VolBackendFs
285+
// klog.Info("Filesystemname", filesystemName)
286+
// filesystemDetails, err := scVol.Connector.GetFilesystemDetails(ctx, filesystemName)
287+
// if err != nil {
288+
// klog.Errorf("Unable to get the filesystemdetails")
289+
// }
290+
// klog.Info("filesystem details", filesystemDetails)
291+
// blockInfo := filesystemDetails.Block.BlockSize
292+
// roundedBlock := uint64(math.Floor(float64(scVol.VolSize) / float64(blockInfo)))
293+
// scVol.VolSize = roundedBlock * uint64(blockInfo)
292294

293295
if filesetQuotaBytes != scVol.VolSize {
294296
var hardLimit, softLimit string
@@ -676,6 +678,8 @@ func (cs *ScaleControllerServer) createFilesetVol(ctx context.Context, scVol *sc
676678
}
677679
}
678680
targetBasePath := ""
681+
// changing the quota
682+
679683
if !isCGIndependentFset {
680684
if scVol.VolSize != 0 {
681685
err = cs.setQuota(ctx, scVol, volName)
@@ -738,7 +742,8 @@ func handleUpdateComment(ctx context.Context, scVol *scaleVolume, setAfmAttribut
738742

739743
func (cs *ScaleControllerServer) getVolumeSizeInBytes(req *csi.CreateVolumeRequest) int64 {
740744
capacity := req.GetCapacityRange()
741-
return capacity.GetRequiredBytes()
745+
requiredBytes := capacity.GetRequiredBytes()
746+
return requiredBytes
742747
}
743748

744749
func updateComment(ctx context.Context, scVol *scaleVolume, setAfmAttributes bool, afmTuningParams map[string]interface{}) error {
@@ -917,7 +922,6 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
917922

918923
/* Get volume size in bytes */
919924
volSize := cs.getVolumeSizeInBytes(req)
920-
921925
reqCapabilities := req.GetVolumeCapabilities()
922926
if reqCapabilities == nil {
923927
return nil, status.Error(codes.InvalidArgument, "Volume Capabilities is a required field")
@@ -1109,7 +1113,7 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
11091113
Volume: &csi.Volume{
11101114
VolumeId: volID,
11111115
//CapacityBytes: int64(scaleVol.VolSize), // #nosec G115 -- false positive
1112-
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
1116+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(), // #nosec G115 -- false positive
11131117
VolumeContext: req.GetParameters(),
11141118
ContentSource: volSrc,
11151119
},
@@ -1189,19 +1193,19 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
11891193
if capRange == nil {
11901194
return nil, status.Error(codes.InvalidArgument, "volume range is not provided")
11911195
}
1192-
// #nosec G115 -- false positive
1196+
11931197
// changing capacity here for pvc size in decimal units to align with scale block size
1194-
capacity := uint64(capRange.GetRequiredBytes())
1195-
filesystemname := scaleVol.VolBackendFs
1196-
filesystemDetails, err := scaleVol.Connector.GetFilesystemDetails(ctx, filesystemname)
1197-
if err != nil {
1198-
klog.Errorf("[%s] Create Volume - unable to get filesystem details ", err)
1199-
return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume - unable to get filesystem details for Filesystem", err))
1200-
}
1201-
blockinfo := filesystemDetails.Block.BlockSize
1202-
roundedblock := uint64(math.Floor(float64(capacity) / float64(blockinfo)))
1203-
capacity = roundedblock * uint64(blockinfo)
1204-
klog.Info("new capacity", capacity)
1198+
capacity := uint64(capRange.GetRequiredBytes()) // #nosec G115 -- false positive
1199+
// filesystemName := scaleVol.VolBackendFs
1200+
// filesystemDetails, err := scaleVol.Connector.GetFilesystemDetails(ctx, filesystemName)
1201+
// if err != nil {
1202+
// klog.Errorf("[%s] Create Volume - unable to get filesystem details ", err)
1203+
// return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume - unable to get filesystem details for Filesystem", err))
1204+
// }
1205+
// blockinfo := filesystemDetails.Block.BlockSize
1206+
// roundedblock := uint64(math.Floor(float64(capacity) / float64(blockinfo)))
1207+
// capacity = roundedblock * uint64(blockinfo)
1208+
// klog.Info("new capacity", capacity)
12051209

12061210
targetPath, err = cs.createStaticBasedVol(ctx, scaleVol, filesetName, capacity)
12071211
} else if scaleVol.IsFilesetBased {
@@ -1258,7 +1262,7 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
12581262
Volume: &csi.Volume{
12591263
VolumeId: volID,
12601264
//CapacityBytes: int64(scaleVol.VolSize) // #nosec G115 -- false positive
1261-
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
1265+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(), // #nosec G115 -- false positive
12621266
VolumeContext: req.GetParameters(),
12631267
ContentSource: volSrc,
12641268
},
@@ -1397,16 +1401,17 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
13971401
scaleVol.VolName = volName
13981402
// changing capacity here for pvc size in decimal units to align with scale block size
13991403
//getting the filesystemname
1400-
filesystemname := scaleVol.VolBackendFs
1401-
klog.Info("Filesystemname", filesystemname)
1402-
filesystemdetails, err := cs.Driver.connmap["primary"].GetFilesystemDetails(ctx, filesystemname)
1404+
filesystemName := scaleVol.VolBackendFs
1405+
klog.Info("Filesystemname", filesystemName)
1406+
filesystemDetails, err := scaleVol.Connector.GetFilesystemDetails(ctx, filesystemName)
14031407
if err != nil {
14041408
klog.Errorf("Unable to get the filesystemdetails")
1409+
return nil, false, "", status.Error(codes.Internal, fmt.Sprintf("unable to get filesystem details for Filesystem %s. Error: %v", filesystemName, err))
14051410
}
1406-
klog.Info("filesystem details", filesystemdetails)
1407-
blockinfo := filesystemdetails.Block.BlockSize
1408-
roundedblock := int64(math.Floor(float64(volSize) / float64(blockinfo)))
1409-
volSize = roundedblock * int64(blockinfo)
1411+
klog.V(4).Infof("[%s] filesystemDetails: %+v", utils.GetLoggerId(ctx), filesystemDetails)
1412+
blockInfo := filesystemDetails.Block.BlockSize
1413+
roundedBlock := int64(math.Floor(float64(volSize) / float64(blockInfo)))
1414+
volSize = roundedBlock * int64(blockInfo)
14101415

14111416
// #nosec G115 -- false positive
14121417
if uint64(volSize) > maximumPVSize { // larger than allowed pv size not allowed
@@ -1418,6 +1423,7 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
14181423
scaleVol.VolSize = smallestVolSize
14191424
} else {
14201425
scaleVol.VolSize = uint64(volSize) // #nosec G115 -- false positive
1426+
14211427
}
14221428

14231429
/* Get details for Primary Cluster */
@@ -2040,18 +2046,18 @@ func (cs *ScaleControllerServer) checkCacheVolumeSupport(assembledScaleversion s
20402046
}
20412047

20422048
/*func (cs *ScaleControllerServer) checkGuiHASupport(ctx context.Context, conn connectors.SpectrumScaleConnector) error {
2043-
// Verify IBM Storage Scale Version is not below 5.1.5-0
2049+
// Verify IBM Storage Scale Version is not below 5.1.5-0
20442050
2045-
versionCheck, err := cs.checkMinScaleVersion(ctx, conn, "5150")
2046-
if err != nil {
2047-
return err
2048-
}
2051+
versionCheck, err := cs.checkMinScaleVersion(ctx, conn, "5150")
2052+
if err != nil {
2053+
return err
2054+
}
20492055
2050-
if !versionCheck {
2051-
return status.Error(codes.FailedPrecondition, "the minimum required IBM Storage Scale version for GUI HA support with CSI is 5.1.5-0")
2052-
}
2053-
return nil
2054-
}*/
2056+
if !versionCheck {
2057+
return status.Error(codes.FailedPrecondition, "the minimum required IBM Storage Scale version for GUI HA support with CSI is 5.1.5-0")
2058+
}
2059+
return nil
2060+
}*/
20552061

20562062
func (cs *ScaleControllerServer) validateSnapId(ctx context.Context, scaleVol *scaleVolume, sourcesnapshot *scaleSnapId, newvolume *scaleVolume, assembledScaleversion string) error {
20572063

@@ -2112,12 +2118,12 @@ func (cs *ScaleControllerServer) validateSnapId(ctx context.Context, scaleVol *s
21122118
filesetToCheck = sourcesnapshot.ConsistencyGroup
21132119
}
21142120
/*isFsetLinked, err := conn.IsFilesetLinked(ctx, sourcesnapshot.FsName, filesetToCheck)
2115-
if err != nil {
2116-
return status.Error(codes.Internal, fmt.Sprintf("unable to get fileset link information for [%v]", filesetToCheck))
2117-
}
2118-
if !isFsetLinked {
2119-
return status.Error(codes.Internal, fmt.Sprintf("fileset [%v] of source snapshot is not linked", filesetToCheck))
2120-
}*/
2121+
if err != nil {
2122+
return status.Error(codes.Internal, fmt.Sprintf("unable to get fileset link information for [%v]", filesetToCheck))
2123+
}
2124+
if !isFsetLinked {
2125+
return status.Error(codes.Internal, fmt.Sprintf("fileset [%v] of source snapshot is not linked", filesetToCheck))
2126+
}*/
21212127

21222128
err = cs.checkFileSetLink(ctx, conn, scaleVol, sourcesnapshot.FsName, filesetToCheck, "source snapshot")
21232129
if err != nil {
@@ -2416,18 +2422,18 @@ func (cs *ScaleControllerServer) DeleteFilesetVol(ctx context.Context, Filesyste
24162422
}
24172423

24182424
/* err := conn.UnlinkFileset(ctx, FilesystemName, FilesetName, false)
2419-
if err != nil {
2420-
if strings.Contains(err.Error(), fsetNotFoundErrCode) ||
2421-
strings.Contains(err.Error(), fsetNotFoundErrMsg) { // fileset is already deleted
2422-
klog.V(4).Infof("[%s] fileset seems already deleted - %v", loggerId, err)
2423-
return true, nil
2424-
} else if strings.Contains(err.Error(), fsetLinkNotFoundErrCode) ||
2425-
strings.Contains(err.Error(), fsetLinkNotFoundErrMsg) { // fileset is already unlinked
2426-
klog.V(4).Infof("[%s] fileset seems already unlinked - %v", loggerId, err)
2427-
} else {
2428-
return false, status.Error(codes.Internal, fmt.Sprintf("unable to unlink Fileset [%v] for FS [%v] and clusterId [%v].Error : [%v]", FilesetName, FilesystemName, volumeIdMembers.ClusterId, err))
2429-
}
2430-
}*/
2425+
if err != nil {
2426+
if strings.Contains(err.Error(), fsetNotFoundErrCode) ||
2427+
strings.Contains(err.Error(), fsetNotFoundErrMsg) { // fileset is already deleted
2428+
klog.V(4).Infof("[%s] fileset seems already deleted - %v", loggerId, err)
2429+
return true, nil
2430+
} else if strings.Contains(err.Error(), fsetLinkNotFoundErrCode) ||
2431+
strings.Contains(err.Error(), fsetLinkNotFoundErrMsg) { // fileset is already unlinked
2432+
klog.V(4).Infof("[%s] fileset seems already unlinked - %v", loggerId, err)
2433+
} else {
2434+
return false, status.Error(codes.Internal, fmt.Sprintf("unable to unlink Fileset [%v] for FS [%v] and clusterId [%v].Error : [%v]", FilesetName, FilesystemName, volumeIdMembers.ClusterId, err))
2435+
}
2436+
}*/
24312437

24322438
err := conn.DeleteFileset(ctx, FilesystemName, FilesetName)
24332439
if err != nil {
@@ -2653,14 +2659,14 @@ func (cs *ScaleControllerServer) DeleteVolume(newctx context.Context, req *csi.D
26532659
pfsName := ""
26542660
// getting the primary filesystem name from the path when primary fs is not provided in the cr and pvc is older
26552661
/* if symlinkExists && ifPrimaryDisable {
2656-
parts := strings.Split(volumeIdMembers.Path, "/")
2657-
for i, part := range parts {
2658-
if part == ".volumes" && i >= 2 {
2659-
pfsName = parts[i-2]
2660-
klog.Infof("[%s] DeleteVolume :primary fs from path is [%v]", loggerId, pfsName)
2661-
}
2662-
}
2663-
}*/
2662+
parts := strings.Split(volumeIdMembers.Path, "/")
2663+
for i, part := range parts {
2664+
if part == ".volumes" && i >= 2 {
2665+
pfsName = parts[i-2]
2666+
klog.Infof("[%s] DeleteVolume :primary fs from path is [%v]", loggerId, pfsName)
2667+
}
2668+
}
2669+
}*/
26642670

26652671
relPath := ""
26662672
if volumeIdMembers.StorageClassType != STORAGECLASS_CLASSIC || volumeIdMembers.VolType == FILE_SHALLOWCOPY_VOLUME || !symlinkExists {
@@ -4022,7 +4028,6 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
40224028
return nil, status.Error(codes.InvalidArgument, "capacity range not provided")
40234029
}
40244030
capacity := uint64(capRange.GetRequiredBytes()) // #nosec G115 -- false positive
4025-
40264031
volumeIDMembers, err := getVolIDMembers(volID)
40274032

40284033
if err != nil {
@@ -4059,14 +4064,14 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
40594064
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - unable to get filesystem Name for Filesystem Uid [%v] and clusterId [%v]. Error [%v]", volumeIDMembers.FsUUID, volumeIDMembers.ClusterId, err))
40604065
}
40614066
// changing capacity here for pvc size in decimal units to align with scale block size
4062-
filesystemdetails, err := conn.GetFilesystemDetails(ctx, filesystemName)
4067+
filesystemDetails, err := conn.GetFilesystemDetails(ctx, filesystemName)
40634068
if err != nil {
40644069
klog.Errorf("[%s] ControllerExpandVolume - unable to get filesystem details for Filesystem Uid [%v] and clusterId [%v]. Error [%v]", loggerId, volumeIDMembers.FsUUID, volumeIDMembers.ClusterId, err)
40654070
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - unable to get filesystem details for Filesystem Uid [%v] and clusterId [%v]. Error [%v]", volumeIDMembers.FsUUID, volumeIDMembers.ClusterId, err))
40664071
}
4067-
blockinfo := filesystemdetails.Block.BlockSize
4068-
roundedblock := uint64(math.Floor(float64(capacity) / float64(blockinfo)))
4069-
capacity = roundedblock * uint64(blockinfo)
4072+
blockInfo := filesystemDetails.Block.BlockSize
4073+
roundedBlock := uint64(math.Floor(float64(capacity) / float64(blockInfo)))
4074+
capacity = roundedBlock * uint64(blockInfo)
40704075

40714076
filesetName := volumeIDMembers.FsetName
40724077

0 commit comments

Comments
 (0)