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

fix: stop resize file share when account limit is exceeded #1345

Merged
merged 1 commit into from
Aug 7, 2023
Merged
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: 6 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ type Driver struct {
accountSearchCache azcache.Resource
// a timed cache storing tag removing history (solve account update throttling issue)
removeTagCache azcache.Resource
// a timed cache when resize file share failed due to account limit exceeded
resizeFileShareFailureCache azcache.Resource
}

// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
Expand Down Expand Up @@ -303,6 +305,10 @@ func NewDriver(options *DriverOptions) *Driver {
klog.Fatalf("%v", err)
}

if driver.resizeFileShareFailureCache, err = azcache.NewTimedCache(3*time.Minute, getter, false); err != nil {
klog.Fatalf("%v", err)
}

return &driver
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/azurefile/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,16 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
subsID = d.cloud.SubscriptionID
}

if accountName != "" {
cache, err := d.resizeFileShareFailureCache.Get(accountName, azcache.CacheReadTypeDefault)
if err != nil {
return nil, status.Errorf(codes.Internal, "resizeFileShareFailureCache(%s) failed with error: %v", accountName, err)
}
if cache != nil {
return nil, status.Errorf(codes.Internal, "account(%s) is in %s, wait for a few minutes to retry", accountName, accountLimitExceedManagementAPI)
}
}

mc := metrics.NewMetricContext(azureFileCSIDriverName, "controller_expand_volume", resourceGroupName, subsID, d.Name)
isOperationSucceeded := false
defer func() {
Expand All @@ -1060,6 +1070,11 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
}

if err = d.ResizeFileShare(ctx, subsID, resourceGroupName, accountName, fileShareName, int(requestGiB), secrets); err != nil {
if strings.Contains(err.Error(), accountLimitExceedManagementAPI) || strings.Contains(err.Error(), accountLimitExceedDataPlaneAPI) {
if accountName != "" {
d.resizeFileShareFailureCache.Set(accountName, "")
}
}
return nil, status.Errorf(codes.Internal, "expand volume error: %v", err)
}

Expand Down
Loading