@@ -73,9 +73,10 @@ type ScaleControllerServer struct {
73
73
74
74
func (cs * ScaleControllerServer ) IfSameVolReqInProcess (scVol * scaleVolume ) (bool , error ) {
75
75
capacity , volpresent := cs .Driver .reqmap [scVol .VolName ]
76
+
76
77
if volpresent {
77
78
/* #nosec G115 -- false positive */
78
- if capacity == int64 (scVol .VolSize ) {
79
+ if int64 (scVol .VolSize ) == capacity {
79
80
return true , nil
80
81
} else {
81
82
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
269
270
}
270
271
271
272
filesetQuotaBytes , err := ConvertToBytes (quota )
273
+
272
274
if err != nil {
273
275
if strings .Contains (err .Error (), "invalid number specified" ) {
274
276
// Invalid number specified means quota is not set
@@ -279,16 +281,16 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
279
281
}
280
282
281
283
// 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 )
292
294
293
295
if filesetQuotaBytes != scVol .VolSize {
294
296
var hardLimit , softLimit string
@@ -676,6 +678,8 @@ func (cs *ScaleControllerServer) createFilesetVol(ctx context.Context, scVol *sc
676
678
}
677
679
}
678
680
targetBasePath := ""
681
+ // changing the quota
682
+
679
683
if ! isCGIndependentFset {
680
684
if scVol .VolSize != 0 {
681
685
err = cs .setQuota (ctx , scVol , volName )
@@ -738,7 +742,8 @@ func handleUpdateComment(ctx context.Context, scVol *scaleVolume, setAfmAttribut
738
742
739
743
func (cs * ScaleControllerServer ) getVolumeSizeInBytes (req * csi.CreateVolumeRequest ) int64 {
740
744
capacity := req .GetCapacityRange ()
741
- return capacity .GetRequiredBytes ()
745
+ requiredBytes := capacity .GetRequiredBytes ()
746
+ return requiredBytes
742
747
}
743
748
744
749
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
917
922
918
923
/* Get volume size in bytes */
919
924
volSize := cs .getVolumeSizeInBytes (req )
920
-
921
925
reqCapabilities := req .GetVolumeCapabilities ()
922
926
if reqCapabilities == nil {
923
927
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
1109
1113
Volume : & csi.Volume {
1110
1114
VolumeId : volID ,
1111
1115
//CapacityBytes: int64(scaleVol.VolSize), // #nosec G115 -- false positive
1112
- CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (),
1116
+ CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (), // #nosec G115 -- false positive
1113
1117
VolumeContext : req .GetParameters (),
1114
1118
ContentSource : volSrc ,
1115
1119
},
@@ -1189,19 +1193,19 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
1189
1193
if capRange == nil {
1190
1194
return nil , status .Error (codes .InvalidArgument , "volume range is not provided" )
1191
1195
}
1192
- // #nosec G115 -- false positive
1196
+
1193
1197
// 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)
1205
1209
1206
1210
targetPath , err = cs .createStaticBasedVol (ctx , scaleVol , filesetName , capacity )
1207
1211
} else if scaleVol .IsFilesetBased {
@@ -1258,7 +1262,7 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
1258
1262
Volume : & csi.Volume {
1259
1263
VolumeId : volID ,
1260
1264
//CapacityBytes: int64(scaleVol.VolSize) // #nosec G115 -- false positive
1261
- CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (),
1265
+ CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (), // #nosec G115 -- false positive
1262
1266
VolumeContext : req .GetParameters (),
1263
1267
ContentSource : volSrc ,
1264
1268
},
@@ -1397,16 +1401,17 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
1397
1401
scaleVol .VolName = volName
1398
1402
// changing capacity here for pvc size in decimal units to align with scale block size
1399
1403
//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 )
1403
1407
if err != nil {
1404
1408
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 ))
1405
1410
}
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 )
1410
1415
1411
1416
// #nosec G115 -- false positive
1412
1417
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
1418
1423
scaleVol .VolSize = smallestVolSize
1419
1424
} else {
1420
1425
scaleVol .VolSize = uint64 (volSize ) // #nosec G115 -- false positive
1426
+
1421
1427
}
1422
1428
1423
1429
/* Get details for Primary Cluster */
@@ -2040,18 +2046,18 @@ func (cs *ScaleControllerServer) checkCacheVolumeSupport(assembledScaleversion s
2040
2046
}
2041
2047
2042
2048
/*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
2044
2050
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
+ }
2049
2055
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
+ }*/
2055
2061
2056
2062
func (cs * ScaleControllerServer ) validateSnapId (ctx context.Context , scaleVol * scaleVolume , sourcesnapshot * scaleSnapId , newvolume * scaleVolume , assembledScaleversion string ) error {
2057
2063
@@ -2112,12 +2118,12 @@ func (cs *ScaleControllerServer) validateSnapId(ctx context.Context, scaleVol *s
2112
2118
filesetToCheck = sourcesnapshot .ConsistencyGroup
2113
2119
}
2114
2120
/*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
+ }*/
2121
2127
2122
2128
err = cs .checkFileSetLink (ctx , conn , scaleVol , sourcesnapshot .FsName , filesetToCheck , "source snapshot" )
2123
2129
if err != nil {
@@ -2416,18 +2422,18 @@ func (cs *ScaleControllerServer) DeleteFilesetVol(ctx context.Context, Filesyste
2416
2422
}
2417
2423
2418
2424
/* 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
+ }*/
2431
2437
2432
2438
err := conn .DeleteFileset (ctx , FilesystemName , FilesetName )
2433
2439
if err != nil {
@@ -2653,14 +2659,14 @@ func (cs *ScaleControllerServer) DeleteVolume(newctx context.Context, req *csi.D
2653
2659
pfsName := ""
2654
2660
// getting the primary filesystem name from the path when primary fs is not provided in the cr and pvc is older
2655
2661
/* 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
+ }*/
2664
2670
2665
2671
relPath := ""
2666
2672
if volumeIdMembers .StorageClassType != STORAGECLASS_CLASSIC || volumeIdMembers .VolType == FILE_SHALLOWCOPY_VOLUME || ! symlinkExists {
@@ -4022,7 +4028,6 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
4022
4028
return nil , status .Error (codes .InvalidArgument , "capacity range not provided" )
4023
4029
}
4024
4030
capacity := uint64 (capRange .GetRequiredBytes ()) // #nosec G115 -- false positive
4025
-
4026
4031
volumeIDMembers , err := getVolIDMembers (volID )
4027
4032
4028
4033
if err != nil {
@@ -4059,14 +4064,14 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
4059
4064
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 ))
4060
4065
}
4061
4066
// 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 )
4063
4068
if err != nil {
4064
4069
klog .Errorf ("[%s] ControllerExpandVolume - unable to get filesystem details for Filesystem Uid [%v] and clusterId [%v]. Error [%v]" , loggerId , volumeIDMembers .FsUUID , volumeIDMembers .ClusterId , err )
4065
4070
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 ))
4066
4071
}
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 )
4070
4075
4071
4076
filesetName := volumeIDMembers .FsetName
4072
4077
0 commit comments