Skip to content

Commit

Permalink
Fixes retry for control client (#2539)
Browse files Browse the repository at this point in the history
* separates retry for control client from data client | increses timeout for retry | adds more error code for retry in control client

* removes create and delete methods for retry in folders
  • Loading branch information
ankitaluthra1 authored Sep 27, 2024
1 parent a4b789d commit 01d2308
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions internal/storage/storageutil/control_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,34 @@ import (
"context"
"fmt"
"os"
"time"

control "cloud.google.com/go/storage/control/apiv2"
"github.com/googleapis/gax-go/v2"
"github.com/googlecloudplatform/gcsfuse/v2/internal/logger"
"google.golang.org/api/option"
"google.golang.org/grpc/codes"
)

func storageControlClientRetryOptions(clientConfig *StorageClientConfig) []gax.CallOption {
return []gax.CallOption{gax.WithRetry(func() gax.Retryer {
return gax.OnErrorFunc(gax.Backoff{
Max: clientConfig.MaxRetrySleep,
Multiplier: clientConfig.RetryMultiplier,
}, ShouldRetry)
})}
return []gax.CallOption{
gax.WithTimeout(300000 * time.Millisecond),
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.ResourceExhausted,
codes.Unavailable,
codes.DeadlineExceeded,
codes.Internal,
codes.Unknown,
}, gax.Backoff{
Max: clientConfig.MaxRetrySleep,
Multiplier: clientConfig.RetryMultiplier,
})
}),
}
}

func setRetryConfigForFolderAPIs(sc *control.StorageControlClient, clientConfig *StorageClientConfig) {
sc.CallOptions.CreateFolder = storageControlClientRetryOptions(clientConfig)
sc.CallOptions.DeleteFolder = storageControlClientRetryOptions(clientConfig)
sc.CallOptions.RenameFolder = storageControlClientRetryOptions(clientConfig)
sc.CallOptions.GetFolder = storageControlClientRetryOptions(clientConfig)
sc.CallOptions.GetStorageLayout = storageControlClientRetryOptions(clientConfig)
Expand Down

0 comments on commit 01d2308

Please sign in to comment.