Skip to content

Commit 59ce8ec

Browse files
authored
pvc size shouldn't more than scale allowed size (#1226)
* pvc size shouldn't more than scale allowed size Signed-off-by: badri-pathak <[email protected]> * handled the failure on wrong values Signed-off-by: badri-pathak <[email protected]> * error on wrong pvc size Signed-off-by: badri-pathak <[email protected]> * error on wrong pvc size Signed-off-by: badri-pathak <[email protected]> * error on wrong pvc size Signed-off-by: badri-pathak <[email protected]> * updated log to GiB Signed-off-by: badri-pathak <[email protected]> * for create volume of lightweight Signed-off-by: badri-pathak <[email protected]> --------- Signed-off-by: badri-pathak <[email protected]>
1 parent c2ce569 commit 59ce8ec

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

driver/csiplugin/controllerserver.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ const (
4848
filesetUnlinkedPath = "--"
4949
ResponseStatusUnknown = "UNKNOWN"
5050
oneGB uint64 = 1024 * 1024 * 1024
51-
smallestVolSize uint64 = oneGB // 1GB
52-
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
51+
smallestVolSize uint64 = oneGB // 1GB
52+
maximumPVSize uint64 = 931322 * 1024 * 1024 * 1024 * 1024 // 999999999999999K
53+
maximumPVSizeForLog = "953673728GiB"
54+
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
5355
cgPrefixLen = 37
5456
softQuotaPercent = 70 // This value is % of the hardQuotaLimit e.g. 70%
5557

@@ -1081,6 +1083,11 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
10811083
}
10821084

10831085
scaleVol.VolName = volName
1086+
1087+
// larger than allowed pv size not allowed
1088+
if uint64(volSize) > maximumPVSize {
1089+
return nil, false, "", fmt.Errorf("failed to create volume, request volume size: [%v] in Bytes is greater than the allowed PV max size: [%v]", uint64(volSize), maximumPVSizeForLog)
1090+
}
10841091
if scaleVol.IsFilesetBased && uint64(volSize) < smallestVolSize {
10851092
scaleVol.VolSize = smallestVolSize
10861093
} else {
@@ -3222,6 +3229,11 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
32223229
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - volume expansion is not supported for shallow copy volume %s", volID))
32233230
}
32243231

3232+
if capacity > maximumPVSize {
3233+
klog.Errorf("[%s] ControllerExpandVolume - Volume expansion volID:[%v] with requested volSize:[%v] in Bytes is not allowed beyond max PV size:[%v]", loggerId, volID, capacity, maximumPVSizeForLog)
3234+
return &csi.ControllerExpandVolumeResponse{NodeExpansionRequired: false}, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - Volume expansion volID:[%v] with requested volSize:[%v] in Bytes is not allowed beyond max PV size:[%v]", volID, capacity, maximumPVSizeForLog))
3235+
}
3236+
32253237
// For lightweight return volume expanded as no action is required
32263238
if !volumeIDMembers.IsFilesetBased {
32273239
return &csi.ControllerExpandVolumeResponse{

0 commit comments

Comments
 (0)