@@ -38,8 +38,8 @@ const (
38
38
AccessPointMode = "efs-ap"
39
39
AzName = "az"
40
40
BasePath = "basePath"
41
- DefaultGidMin = 50000
42
- DefaultGidMax = 7000000
41
+ DefaultGidMin = int64 ( 50000 )
42
+ DefaultGidMax = DefaultGidMin + cloud . AccessPointPerFsLimit
43
43
DefaultTagKey = "efs.csi.aws.com/cluster"
44
44
DefaultTagValue = "true"
45
45
DirectoryPerms = "directoryPerms"
@@ -120,8 +120,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
120
120
azName string
121
121
basePath string
122
122
gid int64
123
- gidMin int
124
- gidMax int
123
+ gidMin int64
124
+ gidMax int64
125
125
localCloud cloud.Cloud
126
126
provisioningMode string
127
127
roleArn string
@@ -189,7 +189,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
189
189
}
190
190
191
191
if value , ok := volumeParams [GidMin ]; ok {
192
- gidMin , err = strconv .Atoi (value )
192
+ gidMin , err = strconv .ParseInt (value , 10 , 64 )
193
193
if err != nil {
194
194
return nil , status .Errorf (codes .InvalidArgument , "Failed to parse invalid %v: %v" , GidMin , err )
195
195
}
@@ -203,7 +203,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
203
203
if gidMin == 0 {
204
204
return nil , status .Errorf (codes .InvalidArgument , "Missing %v parameter" , GidMin )
205
205
}
206
- gidMax , err = strconv .Atoi (value )
206
+ gidMax , err = strconv .ParseInt (value , 10 , 64 )
207
207
if err != nil {
208
208
return nil , status .Errorf (codes .InvalidArgument , "Failed to parse invalid %v: %v" , GidMax , err )
209
209
}
@@ -241,20 +241,27 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
241
241
return nil , err
242
242
}
243
243
244
- // Check if file system exists. Describe FS handles appropriate error codes
245
- if _ , err = localCloud .DescribeFileSystem (ctx , accessPointsOptions .FileSystemId ); err != nil {
244
+ // Check if file system exists. Describe FS or List APs handle appropriate error codes
245
+ // With dynamic uid/gid provisioning we can save a call to describe FS, as list APs fails if FS ID does not exist
246
+ var accessPoints []* cloud.AccessPoint
247
+ if uid == - 1 || gid == - 1 {
248
+ accessPoints , err = localCloud .ListAccessPoints (ctx , accessPointsOptions .FileSystemId )
249
+ } else {
250
+ _ , err = localCloud .DescribeFileSystem (ctx , accessPointsOptions .FileSystemId )
251
+ }
252
+ if err != nil {
246
253
if err == cloud .ErrAccessDenied {
247
254
return nil , status .Errorf (codes .Unauthenticated , "Access Denied. Please ensure you have the right AWS permissions: %v" , err )
248
255
}
249
256
if err == cloud .ErrNotFound {
250
257
return nil , status .Errorf (codes .InvalidArgument , "File System does not exist: %v" , err )
251
258
}
252
- return nil , status .Errorf (codes .Internal , "Failed to fetch File System info : %v" , err )
259
+ return nil , status .Errorf (codes .Internal , "Failed to fetch Access Points or Describe File System: %v" , err )
253
260
}
254
261
255
262
var allocatedGid int64
256
263
if uid == - 1 || gid == - 1 {
257
- allocatedGid , err = d .gidAllocator .getNextGid (ctx , localCloud , accessPointsOptions .FileSystemId , gidMin , gidMax )
264
+ allocatedGid , err = d .gidAllocator .getNextGid (accessPointsOptions .FileSystemId , accessPoints , gidMin , gidMax )
258
265
if err != nil {
259
266
return nil , err
260
267
}
0 commit comments