Skip to content

Commit fff75ce

Browse files
committed
Make Volume resizing/creation timeout scale with volume size.
1 parent bea5a26 commit fff75ce

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

pkg/cloud/cloud.go

+16-9
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ const (
4141
// PollCheckInterval specifies the interval to check if filesystem is ready;
4242
// needs to be shorter than the provisioner timeout
4343
PollCheckInterval = 30 * time.Second
44-
// PollCheckTimeout specifies the time limit for polling DescribeFileSystems
45-
// for a completed create/update operation. FSx for Lustre filesystem
46-
// creation time is around 5 minutes, and update time varies depending on
47-
// target file system values
48-
PollCheckTimeout = 10 * time.Minute
44+
// PollCheckTimeoutConstant & PollCheckTimeoutLinearFactor define the time limit
45+
// for polling DescribeFileSystems for a completed create/update operation.
46+
// FSx for Lustre filesystem creation time is around 5 minutes, and update
47+
// time varies depending on target file system values. To handle varying creation
48+
// times, the driver will wait at least PollCheckTimeoutConstant, but will
49+
// increase the timeout linearly with PollCheckTimeoutLinearFactor (unit is duration/GiB)
50+
PollCheckTimeoutConstant = 10 * time.Minute
51+
PollCheckTimeoutLinearFactor = 5 * time.Millisecond
4952
)
5053

5154
// Tags
@@ -117,7 +120,7 @@ type Cloud interface {
117120
ResizeFileSystem(ctx context.Context, fileSystemId string, newSizeGiB int64) (int64, error)
118121
DeleteFileSystem(ctx context.Context, fileSystemId string) (err error)
119122
DescribeFileSystem(ctx context.Context, fileSystemId string) (fs *FileSystem, err error)
120-
WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error
123+
WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, sizeGiB int64) error
121124
WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error
122125
}
123126

@@ -329,8 +332,12 @@ func (c *cloud) DescribeFileSystem(ctx context.Context, fileSystemId string) (*F
329332
}, nil
330333
}
331334

332-
func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error {
333-
err := wait.Poll(PollCheckInterval, PollCheckTimeout, func() (done bool, err error) {
335+
func CalcPollTimeout(sizeGiB int64) time.Duration {
336+
return time.Duration(int64(PollCheckTimeoutConstant) + sizeGiB*int64(PollCheckTimeoutLinearFactor))
337+
}
338+
339+
func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, sizeGiB int64) error {
340+
err := wait.Poll(PollCheckInterval, CalcPollTimeout(sizeGiB), func() (done bool, err error) {
334341
fs, err := c.getFileSystem(ctx, fileSystemId)
335342
if err != nil {
336343
return true, err
@@ -352,7 +359,7 @@ func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId str
352359
// WaitForFileSystemResize polls the FSx API for status of the update operation with the given target storage
353360
// capacity. The polling terminates when the update operation reaches a completed, failed, or unknown state.
354361
func (c *cloud) WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error {
355-
err := wait.PollImmediate(PollCheckInterval, PollCheckTimeout, func() (done bool, err error) {
362+
err := wait.PollImmediate(PollCheckInterval, CalcPollTimeout(resizeGiB), func() (done bool, err error) {
356363
updateAction, err := c.getUpdateResizeAdministrativeAction(ctx, fileSystemId, resizeGiB)
357364
if err != nil {
358365
return true, err

pkg/cloud/fakes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (c *FakeCloudProvider) DescribeFileSystem(ctx context.Context, volumeID str
9898
return nil, ErrNotFound
9999
}
100100

101-
func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error {
101+
func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, sizeGiB int64) error {
102102
return nil
103103
}
104104

pkg/driver/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
236236
}
237237
}
238238

239-
err = d.cloud.WaitForFileSystemAvailable(ctx, fs.FileSystemId)
239+
err = d.cloud.WaitForFileSystemAvailable(ctx, fs.FileSystemId, fsOptions.CapacityGiB)
240240
if err != nil {
241241
return nil, status.Errorf(codes.Internal, "Filesystem is not ready: %v", err)
242242
}

0 commit comments

Comments
 (0)