Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SC can set min PV size and condition for MAX PV Size limit #1150

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions driver/csiplugin/connectors/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const (
UserSpecifiedShared string = "shared"
AFMModeSecondary string = "secondary"
FilesetComment string = "Fileset created by IBM Container Storage Interface driver"
UserSpecifiedPVMinSize string = "pvMinSize"
)

func GetSpectrumScaleConnector(ctx context.Context, config settings.Clusters) (SpectrumScaleConnector, error) {
Expand Down
52 changes: 38 additions & 14 deletions driver/csiplugin/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/klog/v2"
)

const (
no = "no"
yes = "yes"
notFound = "NOT_FOUND"
filesystemTypeRemote = "remote"
filesystemMounted = "mounted"
filesetUnlinkedPath = "--"
ResponseStatusUnknown = "UNKNOWN"
oneGB uint64 = 1024 * 1024 * 1024
smallestVolSize uint64 = oneGB // 1GB
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
cgPrefixLen = 37
no = "no"
yes = "yes"
notFound = "NOT_FOUND"
filesystemTypeRemote = "remote"
filesystemMounted = "mounted"
filesetUnlinkedPath = "--"
ResponseStatusUnknown = "UNKNOWN"
oneGB uint64 = 1024 * 1024 * 1024
defaultSmallestVolSize uint64 = oneGB // 1GB
maximumPVSize uint64 = 931322 * 1024 * 1024 * 1024 * 1024 // 999999999999999K
defaultSnapWindow = "30" // default snapWindow for Consistency Group snapshots is 30 minutes
cgPrefixLen = 37

discoverCGFileset = "DISCOVER_CG_FILESET"
discoverCGFilesetDisabled = "DISABLED"
Expand Down Expand Up @@ -564,7 +566,7 @@ func checkSCSupportedParams(params map[string]string) (string, bool) {
"csi.storage.k8s.io/pvc/namespace", "storage.kubernetes.io/csiProvisionerIdentity",
"volBackendFs", "volDirBasePath", "uid", "gid", "permissions",
"clusterId", "filesetType", "parentFileset", "inodeLimit", "nodeClass",
"version", "tier", "compression", "consistencyGroup", "shared":
"version", "tier", "compression", "consistencyGroup", "shared", "pvMinSize":
// These are valid parameters, do nothing here
default:
invalidParams = append(invalidParams, k)
Expand Down Expand Up @@ -880,11 +882,28 @@ func (cs *ScaleControllerServer) setScaleVolume(ctx context.Context, req *csi.Cr
}

scaleVol.VolName = volName
if scaleVol.IsFilesetBased && uint64(volSize) < smallestVolSize {
scaleVol.VolSize = smallestVolSize
// larger than allowed pv size not allowed
if scaleVol.IsFilesetBased && uint64(volSize) > maximumPVSize {
return nil, false, "", fmt.Errorf("failed to create volume, request volume size: [%v] is greater than the allowed PV max size: [%v]", uint64(volSize), maximumPVSize)
}
// scaleVol.PVMinSize set from storage class
if scaleVol.IsFilesetBased && scaleVol.PVMinSize != "" {
pvMinSizeParsed, err := resource.ParseQuantity(scaleVol.PVMinSize)
if err != nil {
return nil, false, "", err
}
minVolSize := uint64(pvMinSizeParsed.Value())
if uint64(volSize) < minVolSize {
scaleVol.VolSize = minVolSize
} else {
scaleVol.VolSize = uint64(volSize)
}
} else if scaleVol.IsFilesetBased && uint64(volSize) < defaultSmallestVolSize {
scaleVol.VolSize = defaultSmallestVolSize
} else {
scaleVol.VolSize = uint64(volSize)
}
klog.V(6).Infof("[%s] setScaleVolume: scaleVol VolSize set is [%v]", utils.GetLoggerId(ctx), scaleVol.VolSize)

/* Get details for Primary Cluster */
primaryConn, symlinkDirRelativePath, primaryFS, primaryFSMount, symlinkDirAbsolutePath, primaryClusterID, err := cs.getPrimaryClusterDetails(ctx)
Expand Down Expand Up @@ -2882,6 +2901,11 @@ func (cs *ScaleControllerServer) ControllerExpandVolume(ctx context.Context, req
}, nil
}

if uint64(capacity) > maximumPVSize {
klog.Errorf("[%s] ControllerExpandVolume - Volume expansion volID:[%v] with requested volSize:[%v] is not allowed beyond max PV size:[%v]", loggerId, volID, uint64(capacity), maximumPVSize)
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume - Volume expansion volID:[%v] with requested volSize:[%v] is not allowed beyond max PV size:[%v]", volID, uint64(capacity), maximumPVSize))
}

conn, err := cs.getConnFromClusterID(ctx, volumeIDMembers.ClusterId)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions driver/csiplugin/gpfs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type scaleVolume struct {
Compression string `json:"compression"`
Tier string `json:"tier"`
Shared bool `json:"shared"`
PVMinSize string `json:"pvMinSize"`
}

type scaleVolId struct {
Expand Down Expand Up @@ -135,6 +136,7 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
tier, isTierSpecified := volOptions[connectors.UserSpecifiedTier]
cg, isCGSpecified := volOptions[connectors.UserSpecifiedConsistencyGroup]
shared, isSharedSpecified := volOptions[connectors.UserSpecifiedShared]
pvMinSize, pvMinSizeSpecified := volOptions[connectors.UserSpecifiedPVMinSize]

// Handling empty values
scaleVol.VolDirBasePath = ""
Expand Down Expand Up @@ -389,6 +391,10 @@ func getScaleVolumeOptions(ctx context.Context, volOptions map[string]string) (*
scaleVol.Tier = tier
klog.V(6).Infof("[%s] gpfs_util tier was set: %s", loggerId, tier)
}
if pvMinSizeSpecified && pvMinSize != "" {
scaleVol.PVMinSize = pvMinSize
klog.V(4).Infof("[%s] gpfs_util pvMinSize was set to %s", loggerId, pvMinSize)
}

return scaleVol, nil
}
Expand Down