Skip to content
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

Make Volume creation timeout configurable #384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type Cloud interface {
ResizeFileSystem(ctx context.Context, fileSystemId string, newSizeGiB int64) (int64, error)
DeleteFileSystem(ctx context.Context, fileSystemId string) (err error)
DescribeFileSystem(ctx context.Context, fileSystemId string) (fs *FileSystem, err error)
WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error
WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, timeout time.Duration) error
WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error
}

Expand Down Expand Up @@ -329,8 +329,8 @@ func (c *cloud) DescribeFileSystem(ctx context.Context, fileSystemId string) (*F
}, nil
}

func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error {
err := wait.Poll(PollCheckInterval, PollCheckTimeout, func() (done bool, err error) {
func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, timeout time.Duration) error {
err := wait.Poll(PollCheckInterval, timeout, func() (done bool, err error) {
fs, err := c.getFileSystem(ctx, fileSystemId)
if err != nil {
return true, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/fakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *FakeCloudProvider) DescribeFileSystem(ctx context.Context, volumeID str
return nil, ErrNotFound
}

func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error {
func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string, timeout time.Duration) error {
return nil
}

Expand Down
13 changes: 12 additions & 1 deletion pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"strconv"
"strings"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -69,6 +70,7 @@ const (
volumeParamsDataCompressionType = "dataCompressionType"
volumeParamsWeeklyMaintenanceStartTime = "weeklyMaintenanceStartTime"
volumeParamsFileSystemTypeVersion = "fileSystemTypeVersion"
volumeParamsPollTimeout = "pollTimeout"
volumeParamsExtraTags = "extraTags"
)

Expand Down Expand Up @@ -220,6 +222,15 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
tagArray = strings.Split(optionsTags, ",")
}

pollTimeout := cloud.PollCheckTimeout
if val, ok := volumeParams[volumeParamsPollTimeout]; ok {
n, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return nil, status.Error(codes.InvalidArgument, "pollTimeout must be a number")
}
pollTimeout = time.Duration(n) * time.Second
}

if val, ok := volumeParams[volumeParamsExtraTags]; ok {
extraTags := strings.Split(val, ",")
tagArray = append(tagArray, extraTags...)
Expand All @@ -236,7 +247,7 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
}
}

err = d.cloud.WaitForFileSystemAvailable(ctx, fs.FileSystemId)
err = d.cloud.WaitForFileSystemAvailable(ctx, fs.FileSystemId, pollTimeout)
if err != nil {
return nil, status.Errorf(codes.Internal, "Filesystem is not ready: %v", err)
}
Expand Down