Skip to content

Commit 0b1483e

Browse files
check related to block size
Signed-off-by: shravani <[email protected]>
1 parent 8b58bee commit 0b1483e

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

driver/csiplugin/controllerserver.go

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ type ScaleControllerServer struct {
7373

7474
func (cs *ScaleControllerServer) IfSameVolReqInProcess(scVol *scaleVolume, requestedSize int64) (bool, error) {
7575
capacity, volpresent := cs.Driver.reqmap[scVol.VolName]
76+
7677
if volpresent {
7778
/* #nosec G115 -- false positive */
79+
<<<<<<< Updated upstream
7880
if capacity == requestedSize {
81+
=======
82+
if int64(scVol.VolSize) == capacity {
83+
>>>>>>> Stashed changes
7984
return true, nil
8085
} else {
8186
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 +274,7 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
269274
}
270275

271276
filesetQuotaBytes, err := ConvertToBytes(quota)
277+
272278
if err != nil {
273279
if strings.Contains(err.Error(), "invalid number specified") {
274280
// Invalid number specified means quota is not set
@@ -278,6 +284,21 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
278284
}
279285
}
280286

287+
<<<<<<< Updated upstream
288+
=======
289+
// changing volsize here for pvc size in decimal units to align with scale block size
290+
// filesystemName := scVol.VolBackendFs
291+
// klog.Info("Filesystemname", filesystemName)
292+
// filesystemDetails, err := scVol.Connector.GetFilesystemDetails(ctx, filesystemName)
293+
// if err != nil {
294+
// klog.Errorf("Unable to get the filesystemdetails")
295+
// }
296+
// klog.Info("filesystem details", filesystemDetails)
297+
// blockInfo := filesystemDetails.Block.BlockSize
298+
// roundedBlock := uint64(math.Floor(float64(scVol.VolSize) / float64(blockInfo)))
299+
// scVol.VolSize = roundedBlock * uint64(blockInfo)
300+
301+
>>>>>>> Stashed changes
281302
if filesetQuotaBytes != scVol.VolSize {
282303
var hardLimit, softLimit string
283304
hardLimit = strconv.FormatUint(scVol.VolSize, 10)
@@ -664,6 +685,8 @@ func (cs *ScaleControllerServer) createFilesetVol(ctx context.Context, scVol *sc
664685
}
665686
}
666687
targetBasePath := ""
688+
// changing the quota
689+
667690
if !isCGIndependentFset {
668691
if scVol.VolSize != 0 {
669692
err = cs.setQuota(ctx, scVol, volName)
@@ -726,7 +749,8 @@ func handleUpdateComment(ctx context.Context, scVol *scaleVolume, setAfmAttribut
726749

727750
func (cs *ScaleControllerServer) getVolumeSizeInBytes(req *csi.CreateVolumeRequest) int64 {
728751
capacity := req.GetCapacityRange()
729-
return capacity.GetRequiredBytes()
752+
requiredBytes := capacity.GetRequiredBytes()
753+
return requiredBytes
730754
}
731755

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

906930
/* Get volume size in bytes */
907931
volSize := cs.getVolumeSizeInBytes(req)
908-
909932
reqCapabilities := req.GetVolumeCapabilities()
910933
if reqCapabilities == nil {
911934
return nil, status.Error(codes.InvalidArgument, "Volume Capabilities is a required field")
@@ -1095,7 +1118,12 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
10951118

10961119
return &csi.CreateVolumeResponse{
10971120
Volume: &csi.Volume{
1121+
<<<<<<< Updated upstream
10981122
VolumeId: volID,
1123+
=======
1124+
VolumeId: volID,
1125+
//CapacityBytes: int64(scaleVol.VolSize), // #nosec G115 -- false positive
1126+
>>>>>>> Stashed changes
10991127
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(), // #nosec G115 -- false positive
11001128
VolumeContext: req.GetParameters(),
11011129
ContentSource: volSrc,
@@ -1178,7 +1206,24 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
11781206
if capRange == nil {
11791207
return nil, status.Error(codes.InvalidArgument, "volume range is not provided")
11801208
}
1209+
<<<<<<< Updated upstream
1210+
capacity := uint64(capRange.GetRequiredBytes()) // #nosec G115 -- false positive
1211+
=======
1212+
1213+
// changing capacity here for pvc size in decimal units to align with scale block size
11811214
capacity := uint64(capRange.GetRequiredBytes()) // #nosec G115 -- false positive
1215+
// filesystemName := scaleVol.VolBackendFs
1216+
// filesystemDetails, err := scaleVol.Connector.GetFilesystemDetails(ctx, filesystemName)
1217+
// if err != nil {
1218+
// klog.Errorf("[%s] Create Volume - unable to get filesystem details ", err)
1219+
// return nil, status.Error(codes.Internal, fmt.Sprintf("CreateVolume - unable to get filesystem details for Filesystem", err))
1220+
// }
1221+
// blockinfo := filesystemDetails.Block.BlockSize
1222+
// roundedblock := uint64(math.Floor(float64(capacity) / float64(blockinfo)))
1223+
// capacity = roundedblock * uint64(blockinfo)
1224+
// klog.Info("new capacity", capacity)
1225+
1226+
>>>>>>> Stashed changes
11821227
targetPath, err = cs.createStaticBasedVol(ctx, scaleVol, filesetName, capacity)
11831228
} else if scaleVol.IsFilesetBased {
11841229
targetPath, err = cs.createFilesetBasedVol(ctx, scaleVol, isCGVolume, volFsInfo.Type, req.Secrets, afmTuningParams, gatewayNodeName)
@@ -1232,7 +1277,12 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
12321277

12331278
return &csi.CreateVolumeResponse{
12341279
Volume: &csi.Volume{
1280+
<<<<<<< Updated upstream
12351281
VolumeId: volID,
1282+
=======
1283+
VolumeId: volID,
1284+
//CapacityBytes: int64(scaleVol.VolSize) // #nosec G115 -- false positive
1285+
>>>>>>> Stashed changes
12361286
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(), // #nosec G115 -- false positive
12371287
VolumeContext: req.GetParameters(),
12381288
ContentSource: volSrc,
@@ -1374,9 +1424,15 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
13741424
//getting the filesystemname
13751425
filesystemName := scaleVol.VolBackendFs
13761426
klog.Info("Filesystemname", filesystemName)
1427+
<<<<<<< Updated upstream
13771428
filesystemDetails, err := cs.Driver.connmap["primary"].GetFilesystemDetails(ctx, filesystemName)
13781429
if err != nil {
13791430
klog.Errorf("%s Unable to get the filesystemdetails for Filesystem %s. Error: %v", utils.GetLoggerId(ctx), filesystemName, err)
1431+
=======
1432+
filesystemDetails, err := scaleVol.Connector.GetFilesystemDetails(ctx, filesystemName)
1433+
if err != nil {
1434+
klog.Errorf("Unable to get the filesystemdetails")
1435+
>>>>>>> Stashed changes
13801436
return nil, false, "", status.Error(codes.Internal, fmt.Sprintf("unable to get filesystem details for Filesystem %s. Error: %v", filesystemName, err))
13811437
}
13821438
klog.V(4).Infof("[%s] filesystemDetails: %+v", utils.GetLoggerId(ctx), filesystemDetails)
@@ -1394,6 +1450,7 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
13941450
scaleVol.VolSize = smallestVolSize
13951451
} else {
13961452
scaleVol.VolSize = uint64(volSize) // #nosec G115 -- false positive
1453+
13971454
}
13981455

13991456
/* Get details for Primary Cluster */

0 commit comments

Comments
 (0)