Skip to content

Commit 188dd74

Browse files
Fix for issue 8820
1 parent 6950695 commit 188dd74

File tree

1 file changed

+53
-5
lines changed

1 file changed

+53
-5
lines changed

driver/csiplugin/controllerserver.go

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,18 @@ func (cs *ScaleControllerServer) setQuota(ctx context.Context, scVol *scaleVolum
278278
}
279279
}
280280

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+
281293
if filesetQuotaBytes != scVol.VolSize {
282294
var hardLimit, softLimit string
283295
hardLimit = strconv.FormatUint(scVol.VolSize, 10)
@@ -1095,8 +1107,9 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
10951107

10961108
return &csi.CreateVolumeResponse{
10971109
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(),
11001113
VolumeContext: req.GetParameters(),
11011114
ContentSource: volSrc,
11021115
},
@@ -1176,7 +1189,20 @@ func (cs *ScaleControllerServer) CreateVolume(newctx context.Context, req *csi.C
11761189
if capRange == nil {
11771190
return nil, status.Error(codes.InvalidArgument, "volume range is not provided")
11781191
}
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+
11801206
targetPath, err = cs.createStaticBasedVol(ctx, scaleVol, filesetName, capacity)
11811207
} else if scaleVol.IsFilesetBased {
11821208
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
12301256

12311257
return &csi.CreateVolumeResponse{
12321258
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(),
12351262
VolumeContext: req.GetParameters(),
12361263
ContentSource: volSrc,
12371264
},
@@ -1368,6 +1395,18 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
13681395
isCGVolume = true
13691396
}
13701397
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)
13711410

13721411
// #nosec G115 -- false positive
13731412
if uint64(volSize) > maximumPVSize { // larger than allowed pv size not allowed
@@ -4019,6 +4058,15 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
40194058
klog.Errorf("[%s] ControllerExpandVolume - unable to get filesystem Name for Filesystem Uid [%v] and clusterId [%v]. Error [%v]", loggerId, volumeIDMembers.FsUUID, volumeIDMembers.ClusterId, err)
40204059
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))
40214060
}
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)
40224070

40234071
filesetName := volumeIDMembers.FsetName
40244072

0 commit comments

Comments
 (0)