-
Notifications
You must be signed in to change notification settings - Fork 9
Regional file support #132
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,16 @@ func getVolumeParameters(logger *zap.Logger, req *csi.CreateVolumeRequest, confi | |
iops := value | ||
volume.Iops = &iops | ||
} | ||
case Throughput: | ||
// getting throughput value from storage class if it is provided | ||
if len(value) != 0 { | ||
bandwidth, errParse := strconv.ParseInt(value, 10, 32) | ||
if errParse != nil { | ||
err = fmt.Errorf("'<%v>' is invalid, value of '%s' should be an int32 type", value, key) | ||
} else { | ||
volume.VPCVolume.Bandwidth = int32(bandwidth) | ||
} | ||
} | ||
case UID: | ||
uid, err = strconv.Atoi(value) | ||
if err != nil { | ||
|
@@ -329,8 +339,29 @@ func getVolumeParameters(logger *zap.Logger, req *csi.CreateVolumeRequest, confi | |
|
||
//TODO port the code from VPC BLOCK to find region if zone is given | ||
|
||
// validate bandwidth for dp2 profile | ||
if volume.VPCVolume.Profile != nil && volume.VPCVolume.Profile.Name == DP2Profile && volume.VPCVolume.Bandwidth > 0 { | ||
err = fmt.Errorf("bandwidth is not supported for dp2 profile; please remove the property or set it to zero") | ||
logger.Error("getVolumeParameters", zap.NamedError("invalidParameter", err)) | ||
return volume, err | ||
} | ||
|
||
// validation zone and iops for 'rfs' profile | ||
if volume.VPCVolume.Profile != nil && volume.VPCVolume.Profile.Name == RFSProfile { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these code block can be optimised, we are checking Profile != nil again and again |
||
if volume.Iops != nil && len(strings.TrimSpace(*volume.Iops)) > 0 { | ||
err = fmt.Errorf("iops is not supported for rfs profile; please remove the iops parameter from the storage class") | ||
logger.Error("getVolumeParameters", zap.NamedError("invalidParameter", err)) | ||
return volume, err | ||
} | ||
if len(strings.TrimSpace(volume.Az)) > 0 { | ||
err = fmt.Errorf("zone is not supported for rfs profile; please remove the zone parameter from the storage class") | ||
logger.Error("getVolumeParameters", zap.NamedError("invalidParameter", err)) | ||
return volume, err | ||
} | ||
} | ||
|
||
//If the zone is not provided in storage class parameters then we pick from the Topology | ||
if len(strings.TrimSpace(volume.Az)) == 0 { | ||
if len(strings.TrimSpace(volume.Az)) == 0 && volume.VPCVolume.Profile.Name != RFSProfile { | ||
zones, err := pickTargetTopologyParams(req.GetAccessibilityRequirements()) | ||
if err != nil { | ||
err = fmt.Errorf("unable to fetch zone information: '%v'", err) | ||
|
@@ -491,19 +522,19 @@ func overrideParams(logger *zap.Logger, req *csi.CreateVolumeRequest, config *co | |
volume.Region = value | ||
} | ||
case IOPS: | ||
// Override IOPS only for custom or dp2 | ||
if volume.Capacity != nil && volume.VPCVolume.Profile != nil && volume.VPCVolume.Profile.Name == DP2Profile { | ||
var iops int | ||
var check bool | ||
iops, err = strconv.Atoi(value) | ||
if err != nil { | ||
err = fmt.Errorf("%v:<%v> invalid value", key, value) | ||
if len(value) != 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure this code should be released only for 2.0 driver |
||
logger.Info("override (IOPS)", zap.Any(IOPS, value)) | ||
iopsStr := value | ||
volume.Iops = &iopsStr | ||
} | ||
case Throughput: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throughput is only supported for rfs profile, looks code is not uniform somewhere we are checking profile and taking action and somewhere its not |
||
// getting throughput value from storage class if it is provided | ||
if len(value) != 0 { | ||
bandwidth, errParse := strconv.ParseInt(value, 10, 32) | ||
if errParse != nil { | ||
err = fmt.Errorf("'<%v>' is invalid, value of '%s' should be an int32 type", value, key) | ||
} else { | ||
if check, err = isValidCapacityIOPS(*(volume.Capacity), iops, volume.VPCVolume.Profile.Name); check { | ||
iopsStr := value | ||
logger.Info("override", zap.Any(IOPS, value)) | ||
volume.Iops = &iopsStr | ||
} | ||
volume.Bandwidth = int32(bandwidth) | ||
} | ||
} | ||
case SecurityGroupIDs: | ||
|
@@ -587,15 +618,25 @@ func createCSIVolumeResponse(vol provider.Volume, volAccessPointResponse provide | |
|
||
// Update labels for PV objects | ||
labels[VolumeIDLabel] = vol.VolumeID + VolumeIDSeperator + volAccessPointResponse.AccessPointID | ||
labels[VolumeCRNLabel] = vol.CRN | ||
labels[ClusterIDLabel] = clusterID | ||
|
||
if vol.VPCVolume.Profile != nil && vol.VPCVolume.Profile.Name != "" { | ||
labels[ProfileLabel] = vol.VPCVolume.Profile.Name | ||
} | ||
|
||
if vol.VPCVolume.Href != "" { | ||
labels[VolumeHrefLabel] = vol.VPCVolume.Href | ||
} | ||
|
||
labels[VolumeCRNLabel] = vol.CRN | ||
labels[ClusterIDLabel] = clusterID | ||
labels[Tag] = strings.Join(vol.Tags, ",") | ||
if vol.Iops != nil && len(*vol.Iops) > 0 { | ||
labels[IOPSLabel] = *vol.Iops | ||
} | ||
|
||
if vol.VPCVolume.Bandwidth > 0 { | ||
labels[ThroughputLabel] = strconv.Itoa(int(vol.VPCVolume.Bandwidth)) + " " + "mbps" | ||
} | ||
labels[FileShareIDLabel] = vol.VolumeID | ||
labels[FileShareTargetIDLabel] = volAccessPointResponse.AccessPointID | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This we need to enhance so that user will have proper action