Skip to content

Commit fba143f

Browse files
committed
Support for configurable beta
Signed-off-by: Sameer Shaikh <sameer.shaikh@ibm.com>
1 parent 112d81e commit fba143f

File tree

6 files changed

+68
-35
lines changed

6 files changed

+68
-35
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/IBM/ibm-vpc-file-csi-driver
33
go 1.23.10
44

55
require (
6-
github.com/IBM/ibm-csi-common v1.1.21
7-
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250828153241-fa23f9b45442
8-
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250828062308-b1f9bf8df792
6+
github.com/IBM/ibm-csi-common v1.1.22-0.20250831125055-b936fa186fd9
7+
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250831072327-5d1cdeb74991
8+
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250831072948-c3de75b9763b
99
github.com/IBM/secret-utils-lib v1.1.14
1010
github.com/container-storage-interface/spec v1.11.0
1111
github.com/golang/glog v1.2.4

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7 h1:eHgfQl6IeSmzWUyiSi13CvoFYsovoyq
77
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.6.7/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
88
github.com/IBM/go-sdk-core/v5 v5.17.4 h1:VGb9+mRrnS2HpHZFM5hy4J6ppIWnwNrw0G+tLSgcJLc=
99
github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns=
10-
github.com/IBM/ibm-csi-common v1.1.21 h1:/OmjpF+YgmkLmtehFmmfWp9kHGP9iMNkTU/KQDYXzrY=
11-
github.com/IBM/ibm-csi-common v1.1.21/go.mod h1:AgjHhkYgDwYz1OmFGTgtOv+GCMsD67Yel+ZKsY90PYY=
12-
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250828153241-fa23f9b45442 h1:hNrDsM9AaBmLZIi9BGv8jCaWXfkcKV6rerV2Dil+uLU=
13-
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250828153241-fa23f9b45442/go.mod h1:h10C+E4wKGoLlZwIDrYlqq8aBO7Z11FiQx5ZjQGEkvQ=
14-
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250828062308-b1f9bf8df792 h1:tbPgwJoIiwGAeVaMreRE3oV8H1OQSF9l9AhEozTs96M=
15-
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250828062308-b1f9bf8df792/go.mod h1:F9QxX6NZ4LLPGQ6YWVnYpW0JV+H+pZp8RY10PAZ76JA=
10+
github.com/IBM/ibm-csi-common v1.1.22-0.20250831125055-b936fa186fd9 h1:TTXy1XLBaM/+BMYVw0cnJn2cW33xknQkZuucvWUaR8c=
11+
github.com/IBM/ibm-csi-common v1.1.22-0.20250831125055-b936fa186fd9/go.mod h1:AgjHhkYgDwYz1OmFGTgtOv+GCMsD67Yel+ZKsY90PYY=
12+
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250831072327-5d1cdeb74991 h1:HULD+kdxBQZSuSgwQ9Go3yVi0ljxOqqx8eDEtzJhjZw=
13+
github.com/IBM/ibmcloud-volume-file-vpc v1.2.11-0.20250831072327-5d1cdeb74991/go.mod h1:h10C+E4wKGoLlZwIDrYlqq8aBO7Z11FiQx5ZjQGEkvQ=
14+
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250831072948-c3de75b9763b h1:RVBTb8QPQyq6maeBfMpGZL/Y10JyCKE6SBWcxURSW3c=
15+
github.com/IBM/ibmcloud-volume-interface v1.2.14-0.20250831072948-c3de75b9763b/go.mod h1:F9QxX6NZ4LLPGQ6YWVnYpW0JV+H+pZp8RY10PAZ76JA=
1616
github.com/IBM/secret-common-lib v1.1.13 h1:94YIuXew6lBXf0cfhyfM1iNUbUsV34abc4+BGvnXCTQ=
1717
github.com/IBM/secret-common-lib v1.1.13/go.mod h1:33mQHLZyAq7HmS9SYDQXpf0OhBhe4TRHDaRBktDxnm0=
1818
github.com/IBM/secret-utils-lib v1.1.14 h1:Gv5Ca2hZTQMr9+PkOq7AE2lUUnNEeQJ0uiKaxKT1Sdk=

pkg/ibmcsidriver/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// Package ibmcsidriver ...
2020
package ibmcsidriver
2121

22+
import "github.com/IBM/ibm-csi-common/pkg/utils"
23+
2224
const (
2325
// Profile ...
2426
Profile = "profile"
@@ -190,6 +192,9 @@ const (
190192

191193
// ConfigmapDataKey
192194
ConfigmapDataKey = "vpc_subnet_ids"
195+
196+
// MinimumRFSVolumeSizeInBytes ... This is minimum size require for rfs profile
197+
MinimumRFSVolumeSizeInBytes int64 = 1 * utils.GiB
193198
)
194199

195200
// SupportedFS the supported FS types

pkg/ibmcsidriver/controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package ibmcsidriver
2121

2222
import (
23-
"fmt"
2423
"os"
2524
"strings"
2625
"time"
@@ -113,8 +112,7 @@ func (csiCS *CSIControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
113112

114113
// Check if RFS Profile is accessible
115114
if requestedVolume.Profile != nil && requestedVolume.Profile.Name == RFSProfile && !csiCS.Driver.rfsEnabled {
116-
err = fmt.Errorf("RFS Profile is not accessible, please open support ticket on VPC for allowlisting. Restart of VPC FILE CSI Driver is required post allowlisting")
117-
return nil, commonError.GetCSIError(ctxLogger, commonError.VolumeInvalidArguments, requestID, err)
115+
return nil, commonError.GetCSIError(ctxLogger, commonError.ProfileNotAllowlisted, requestID, nil, RFSProfile)
118116
}
119117

120118
// TODO: Determine Zones and Region for the disk

pkg/ibmcsidriver/controller_helper.go

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

pkg/ibmcsidriver/controller_helper_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,44 +44,65 @@ func TestGetRequestedCapacity(t *testing.T) {
4444
testCases := []struct {
4545
testCaseName string
4646
capRange *csi.CapacityRange
47+
profileName string
4748
expectedValue int64
4849
expectedError error
4950
}{
51+
{
52+
testCaseName: "Check minimum size supported by volume provider in case of nil passed as input for rfs profile",
53+
capRange: nil,
54+
profileName: "rfs",
55+
expectedValue: MinimumRFSVolumeSizeInBytes,
56+
expectedError: nil,
57+
},
58+
{
59+
testCaseName: "Check minimum size supported by volume provider in case of lower value passed as input for rfs profile",
60+
capRange: &csi.CapacityRange{RequiredBytes: 1024},
61+
profileName: "rfs",
62+
expectedValue: MinimumRFSVolumeSizeInBytes,
63+
expectedError: nil,
64+
},
5065
{
5166
testCaseName: "Check minimum size supported by volume provider in case of nil passed as input",
67+
profileName: "dp2",
5268
capRange: &csi.CapacityRange{},
5369
expectedValue: utils.MinimumVolumeSizeInBytes,
5470
expectedError: nil,
5571
},
5672
{
5773
testCaseName: "Capacity range is nil",
74+
profileName: "dp2",
5875
capRange: nil,
5976
expectedValue: utils.MinimumVolumeSizeInBytes,
6077
expectedError: nil,
6178
},
6279
{
6380
testCaseName: "Check minimum size supported by volume provider",
81+
profileName: "dp2",
6482
capRange: &csi.CapacityRange{RequiredBytes: 1024,
6583
LimitBytes: utils.MinimumVolumeSizeInBytes},
6684
expectedValue: utils.MinimumVolumeSizeInBytes,
6785
expectedError: nil,
6886
},
6987
{
7088
testCaseName: "Check size passed as actual value",
89+
profileName: "dp2",
7190
capRange: &csi.CapacityRange{RequiredBytes: 11811160064,
7291
LimitBytes: utils.MinimumVolumeSizeInBytes + utils.MinimumVolumeSizeInBytes}, // MinimumVolumeSizeInBytes->10737418240
7392
expectedValue: 11811160064,
7493
expectedError: nil,
7594
},
7695
{
7796
testCaseName: "Expected error check-success",
97+
profileName: "dp2",
7898
capRange: &csi.CapacityRange{RequiredBytes: 1073741824 * 30,
7999
LimitBytes: utils.MinimumVolumeSizeInBytes}, // MinimumVolumeSizeInBytes->10737418240
80100
expectedValue: 0,
81101
expectedError: fmt.Errorf("limit bytes %v is less than required bytes %v", utils.MinimumVolumeSizeInBytes, 1073741824*30),
82102
},
83103
{
84104
testCaseName: "Expected error check against limit byte-success",
105+
profileName: "dp2",
85106
capRange: &csi.CapacityRange{RequiredBytes: utils.MinimumVolumeSizeInBytes - 100,
86107
LimitBytes: 10737418230}, // MinimumVolumeSizeInBytes->10737418240
87108
expectedValue: 0,
@@ -91,7 +112,7 @@ func TestGetRequestedCapacity(t *testing.T) {
91112

92113
for _, testcase := range testCases {
93114
t.Run(testcase.testCaseName, func(t *testing.T) {
94-
sizeCap, err := getRequestedCapacity(testcase.capRange)
115+
sizeCap, err := getRequestedCapacity(testcase.capRange, testcase.profileName)
95116
if testcase.expectedError != nil {
96117
assert.Equal(t, err, testcase.expectedError)
97118
} else {
@@ -739,7 +760,7 @@ func TestGetVolumeParameters(t *testing.T) {
739760
},
740761
expectedVolume: &provider.Volume{},
741762
expectedStatus: true,
742-
expectedError: fmt.Errorf("bandwidth is not supported for dp2 profile; please remove the property or set it to zero"),
763+
expectedError: fmt.Errorf("bandwidth is not supported for dp2 profile; please remove the property"),
743764
},
744765
{
745766
testCaseName: "subnetID is missing if primaryIPAddress is provided",

0 commit comments

Comments
 (0)