@@ -278,6 +278,18 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
278
278
}
279
279
}
280
280
281
+ // 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 )
292
+
281
293
if filesetQuotaBytes != scVol .VolSize {
282
294
var hardLimit , softLimit string
283
295
hardLimit = strconv .FormatUint (scVol .VolSize , 10 )
@@ -1095,8 +1107,9 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
1095
1107
1096
1108
return & csi.CreateVolumeResponse {
1097
1109
Volume : & csi.Volume {
1098
- VolumeId : volID ,
1099
- CapacityBytes : int64 (scaleVol .VolSize ), // #nosec G115 -- false positive
1110
+ VolumeId : volID ,
1111
+ //CapacityBytes: int64(scaleVol.VolSize), // #nosec G115 -- false positive
1112
+ CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (),
1100
1113
VolumeContext : req .GetParameters (),
1101
1114
ContentSource : volSrc ,
1102
1115
},
@@ -1176,7 +1189,20 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
1176
1189
if capRange == nil {
1177
1190
return nil , status .Error (codes .InvalidArgument , "volume range is not provided" )
1178
1191
}
1179
- capacity := uint64 (capRange .GetRequiredBytes ()) // #nosec G115 -- false positive
1192
+ // #nosec G115 -- false positive
1193
+ // 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 )
1205
+
1180
1206
targetPath , err = cs .createStaticBasedVol (ctx , scaleVol , filesetName , capacity )
1181
1207
} else if scaleVol .IsFilesetBased {
1182
1208
targetPath , err = cs .createFilesetBasedVol (ctx , scaleVol , isCGVolume , volFsInfo .Type , req .Secrets , afmTuningParams , gatewayNodeName )
@@ -1230,8 +1256,9 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
1230
1256
1231
1257
return & csi.CreateVolumeResponse {
1232
1258
Volume : & csi.Volume {
1233
- VolumeId : volID ,
1234
- CapacityBytes : int64 (scaleVol .VolSize ), // #nosec G115 -- false positive
1259
+ VolumeId : volID ,
1260
+ //CapacityBytes: int64(scaleVol.VolSize) // #nosec G115 -- false positive
1261
+ CapacityBytes : req .GetCapacityRange ().GetRequiredBytes (),
1235
1262
VolumeContext : req .GetParameters (),
1236
1263
ContentSource : volSrc ,
1237
1264
},
@@ -1368,6 +1395,18 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
1368
1395
isCGVolume = true
1369
1396
}
1370
1397
scaleVol .VolName = volName
1398
+ // changing capacity here for pvc size in decimal units to align with scale block size
1399
+ //getting the filesystemname
1400
+ filesystemname := scaleVol .VolBackendFs
1401
+ klog .Info ("Filesystemname" , filesystemname )
1402
+ filesystemdetails , err := cs .Driver .connmap ["primary" ].GetFilesystemDetails (ctx , filesystemname )
1403
+ if err != nil {
1404
+ klog .Errorf ("Unable to get the filesystemdetails" )
1405
+ }
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 )
1371
1410
1372
1411
// #nosec G115 -- false positive
1373
1412
if uint64 (volSize ) > maximumPVSize { // larger than allowed pv size not allowed
@@ -4019,6 +4058,15 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
4019
4058
klog .Errorf ("[%s] ControllerExpandVolume - unable to get filesystem Name for Filesystem Uid [%v] and clusterId [%v]. Error [%v]" , loggerId , volumeIDMembers .FsUUID , volumeIDMembers .ClusterId , err )
4020
4059
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 ))
4021
4060
}
4061
+ // changing capacity here for pvc size in decimal units to align with scale block size
4062
+ filesystemdetails , err := conn .GetFilesystemDetails (ctx , filesystemName )
4063
+ if err != nil {
4064
+ 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
+ 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
+ }
4067
+ blockinfo := filesystemdetails .Block .BlockSize
4068
+ roundedblock := uint64 (math .Floor (float64 (capacity ) / float64 (blockinfo )))
4069
+ capacity = roundedblock * uint64 (blockinfo )
4022
4070
4023
4071
filesetName := volumeIDMembers .FsetName
4024
4072
0 commit comments