Skip to content

Commit

Permalink
pvc size shouldn't more than scale allowed size (#1226)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
badri-pathak authored Oct 21, 2024
1 parent c2ce569 commit 59ce8ec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions driver/csiplugin/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ const (
filesetUnlinkedPath = "--"
ResponseStatusUnknown = "UNKNOWN"
oneGB uint64 = 1024 * 1024 * 1024
smallestVolSize uint64 = oneGB // 1GB
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
smallestVolSize uint64 = oneGB // 1GB
maximumPVSize uint64 = 931322 * 1024 * 1024 * 1024 * 1024 // 999999999999999K
maximumPVSizeForLog = "953673728GiB"
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
cgPrefixLen = 37
softQuotaPercent = 70 // This value is % of the hardQuotaLimit e.g. 70%

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

scaleVol.VolName = volName

// larger than allowed pv size not allowed
if uint64(volSize) > maximumPVSize {
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)
}
if scaleVol.IsFilesetBased && uint64(volSize) < smallestVolSize {
scaleVol.VolSize = smallestVolSize
} else {
Expand Down Expand Up @@ -3222,6 +3229,11 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - volume expansion is not supported for shallow copy volume %s", volID))
}

if capacity > maximumPVSize {
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)
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))
}

// For lightweight return volume expanded as no action is required
if !volumeIDMembers.IsFilesetBased {
return &csi.ControllerExpandVolumeResponse{
Expand Down

0 comments on commit 59ce8ec

Please sign in to comment.