@@ -65,12 +65,16 @@ var dp2CapacityIopsRanges = []classRange{
6565}
6666
6767// normalize the requested capacity(in GiB) to what is supported by the driver
68- func getRequestedCapacity (capRange * csi.CapacityRange ) (int64 , error ) {
68+ func getRequestedCapacity (capRange * csi.CapacityRange , profileName string ) (int64 , error ) {
6969 // Input is in bytes from csi
7070 var capBytes int64
7171 // Default case where nothing is set
7272 if capRange == nil {
73- capBytes = utils .MinimumVolumeSizeInBytes
73+ if profileName == RFSProfile { // RFS profile minimum size is 1GB
74+ capBytes = MinimumRFSVolumeSizeInBytes
75+ } else {
76+ capBytes = utils .MinimumVolumeSizeInBytes // tierd and custom profile minimum size is 10 GB
77+ }
7478 // returns in GiB
7579 return capBytes , nil
7680 }
@@ -97,7 +101,8 @@ func getRequestedCapacity(capRange *csi.CapacityRange) (int64, error) {
97101
98102 // Limit is more than Required, but larger than Minimum. So we just set capcity to Minimum
99103 // Too small, default
100- if capBytes < utils .MinimumVolumeSizeInBytes {
104+ // If profile is RFS profile then no need to check for minimum size as the RoundUpBytes will giving minimum value as 1 GiB
105+ if capBytes < utils .MinimumVolumeSizeInBytes && profileName != RFSProfile {
101106 capBytes = utils .MinimumVolumeSizeInBytes
102107 }
103108
@@ -277,9 +282,15 @@ func getVolumeParameters(logger *zap.Logger, req *csi.CreateVolumeRequest, confi
277282 }
278283 }
279284
285+ if volume .VPCVolume .Profile == nil {
286+ err = fmt .Errorf ("volume profile is empty, you need to pass valid profile name" )
287+ logger .Error ("getVolumeParameters" , zap .NamedError ("InvalidRequest" , err ))
288+ return volume , err
289+ }
290+
280291 // Get the requested capacity from the request
281292 capacityRange := req .GetCapacityRange ()
282- capBytes , err := getRequestedCapacity (capacityRange )
293+ capBytes , err := getRequestedCapacity (capacityRange , volume . VPCVolume . Profile . Name )
283294 if err != nil {
284295 err = fmt .Errorf ("invalid PVC capacity size: '%v'" , err )
285296 logger .Error ("getVolumeParameters" , zap .NamedError ("invalid parameter" , err ))
@@ -334,26 +345,24 @@ func getVolumeParameters(logger *zap.Logger, req *csi.CreateVolumeRequest, confi
334345
335346 //TODO port the code from VPC BLOCK to find region if zone is given
336347
337- if volume .VPCVolume .Profile != nil {
338- // validate bandwidth for dp2 profile
339- if volume .VPCVolume .Profile .Name == DP2Profile && volume .VPCVolume .Bandwidth > 0 {
340- err = fmt .Errorf ("bandwidth is not supported for dp2 profile; please remove the property or set it to zero" )
348+ // validate bandwidth for dp2 profile
349+ if volume .VPCVolume .Profile .Name == DP2Profile && volume .VPCVolume .Bandwidth >= 0 {
350+ err = fmt .Errorf ("bandwidth is not supported for dp2 profile; please remove the property" )
351+ logger .Error ("getVolumeParameters" , zap .NamedError ("invalidParameter" , err ))
352+ return volume , err
353+ }
354+
355+ // validation zone and iops for 'rfs' profile
356+ if volume .VPCVolume .Profile .Name == RFSProfile {
357+ if volume .Iops != nil && len (strings .TrimSpace (* volume .Iops )) >= 0 {
358+ err = fmt .Errorf ("iops is not supported for rfs profile; please remove the iops parameter from the storage class" )
341359 logger .Error ("getVolumeParameters" , zap .NamedError ("invalidParameter" , err ))
342360 return volume , err
343361 }
344-
345- // validation zone and iops for 'rfs' profile
346- if volume .VPCVolume .Profile .Name == RFSProfile {
347- if volume .Iops != nil && len (strings .TrimSpace (* volume .Iops )) > 0 {
348- err = fmt .Errorf ("iops is not supported for rfs profile; please remove the iops parameter from the storage class" )
349- logger .Error ("getVolumeParameters" , zap .NamedError ("invalidParameter" , err ))
350- return volume , err
351- }
352- if len (strings .TrimSpace (volume .Az )) > 0 {
353- err = fmt .Errorf ("zone is not supported for rfs profile; please remove the zone parameter from the storage class" )
354- logger .Error ("getVolumeParameters" , zap .NamedError ("invalidParameter" , err ))
355- return volume , err
356- }
362+ if len (strings .TrimSpace (volume .Az )) > 0 {
363+ err = fmt .Errorf ("zone is not supported for rfs profile; please remove the zone parameter from the storage class" )
364+ logger .Error ("getVolumeParameters" , zap .NamedError ("invalidParameter" , err ))
365+ return volume , err
357366 }
358367 }
359368
0 commit comments