diff --git a/flags.go b/flags.go index 2d3dd91648..593cd3e273 100644 --- a/flags.go +++ b/flags.go @@ -194,10 +194,9 @@ func newApp() (app *cli.App) { cli.DurationFlag{ Name: "max-retry-sleep", - Value: time.Minute, - Usage: "The maximum duration allowed to sleep in a retry loop with exponential backoff " + - "for failed requests to GCS backend. Once the backoff duration exceeds this limit, the retry stops." + - " The default is 1 minute. A value of 0 disables retries.", + Value: 30 * time.Second, + Usage: "The maximum duration allowed to sleep in a retry loop with exponential backoff for failed requests to GCS backend." + + " Once the backoff duration exceeds this limit, the retry continues with this specified maximum value.", }, cli.IntFlag{ @@ -225,8 +224,8 @@ func newApp() (app *cli.App) { cli.DurationFlag{ Name: "max-retry-duration", - Value: 30 * time.Second, - Usage: "The operation will be retried till the value of max-retry-duration.", + Value: -1 * time.Second, + Usage: "This flag is currently unused.", }, cli.Float64Flag{ diff --git a/flags_test.go b/flags_test.go index 804796ac1a..ffb2f7a57b 100644 --- a/flags_test.go +++ b/flags_test.go @@ -218,14 +218,16 @@ func (t *FlagsTest) Durations() { "--stat-cache-ttl", "1m17s", "--type-cache-ttl", "19ns", "--http-client-timeout", "800ms", - "--max-retry-duration", "30s", + "--max-retry-duration", "-1s", + "--max-retry-sleep", "30s", } f := parseArgs(args) ExpectEq(77*time.Second, f.StatCacheTTL) ExpectEq(19*time.Nanosecond, f.TypeCacheTTL) ExpectEq(800*time.Millisecond, f.HttpClientTimeout) - ExpectEq(30*time.Second, f.MaxRetryDuration) + ExpectEq(-1*time.Second, f.MaxRetryDuration) + ExpectEq(30*time.Second, f.MaxRetrySleep) } func (t *FlagsTest) Maps() { diff --git a/internal/storage/storage_handle.go b/internal/storage/storage_handle.go index 4c263c8fd5..031be36371 100644 --- a/internal/storage/storage_handle.go +++ b/internal/storage/storage_handle.go @@ -83,7 +83,7 @@ func NewStorageHandle(ctx context.Context, clientConfig storageutil.StorageClien // https://github.com/googleapis/google-cloud-go/blob/main/storage/storage.go#L1953 sc.SetRetry( storage.WithBackoff(gax.Backoff{ - Max: clientConfig.MaxRetryDuration, + Max: clientConfig.MaxRetrySleep, Multiplier: clientConfig.RetryMultiplier, }), storage.WithPolicy(storage.RetryAlways), diff --git a/internal/storage/storageutil/client.go b/internal/storage/storageutil/client.go index 3459bab17d..77c125992d 100644 --- a/internal/storage/storageutil/client.go +++ b/internal/storage/storageutil/client.go @@ -32,7 +32,7 @@ type StorageClientConfig struct { MaxConnsPerHost int MaxIdleConnsPerHost int HttpClientTimeout time.Duration - MaxRetryDuration time.Duration + MaxRetrySleep time.Duration RetryMultiplier float64 UserAgent string CustomEndpoint *url.URL diff --git a/internal/storage/storageutil/test_util.go b/internal/storage/storageutil/test_util.go index 56c60a2dc2..970577bb88 100644 --- a/internal/storage/storageutil/test_util.go +++ b/internal/storage/storageutil/test_util.go @@ -33,7 +33,7 @@ func GetDefaultStorageClientConfig() (clientConfig StorageClientConfig) { MaxConnsPerHost: 10, MaxIdleConnsPerHost: 100, HttpClientTimeout: 800 * time.Millisecond, - MaxRetryDuration: 30 * time.Second, + MaxRetrySleep: time.Minute, RetryMultiplier: 2, UserAgent: "gcsfuse/unknown (Go version go1.20-pre3 cl/474093167 +a813be86df) (GCP:gcsfuse)", CustomEndpoint: &url.URL{}, diff --git a/main.go b/main.go index cc628c1397..54684c8d8b 100644 --- a/main.go +++ b/main.go @@ -87,7 +87,7 @@ func createStorageHandle(flags *flagStorage) (storageHandle storage.StorageHandl MaxConnsPerHost: flags.MaxConnsPerHost, MaxIdleConnsPerHost: flags.MaxIdleConnsPerHost, HttpClientTimeout: flags.HttpClientTimeout, - MaxRetryDuration: flags.MaxRetryDuration, + MaxRetrySleep: flags.MaxRetrySleep, RetryMultiplier: flags.RetryMultiplier, UserAgent: getUserAgent(flags.AppName), CustomEndpoint: flags.CustomEndpoint, diff --git a/main_test.go b/main_test.go index 1bfeac0582..9d2d00474e 100644 --- a/main_test.go +++ b/main_test.go @@ -27,7 +27,7 @@ func (t *MainTest) TestCreateStorageHandle() { MaxConnsPerHost: 5, MaxIdleConnsPerHost: 100, HttpClientTimeout: 5, - MaxRetryDuration: 7, + MaxRetrySleep: 7, RetryMultiplier: 2, AppName: "app", KeyFile: "testdata/test_creds.json",