Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
disable retries for congestion control
  • Loading branch information
ashwanthgoli committed Nov 12, 2024
commit eb839e64e394167c4c7ae0f741a59cfa660ea031
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ require (
github.com/richardartoul/molecule v1.0.0
github.com/schollz/progressbar/v3 v3.17.0
github.com/shirou/gopsutil/v4 v4.24.10
github.com/thanos-io/objstore v0.0.0-20241105144332-b598dceacb13
github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97
github.com/twmb/franz-go v1.17.1
github.com/twmb/franz-go/pkg/kadm v1.13.0
github.com/twmb/franz-go/pkg/kfake v0.0.0-20241015013301-cea7aa5d8037
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2585,8 +2585,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.480/go.mod
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.480/go.mod h1:zaBIuDDs+rC74X8Aog+LSu91GFtHYRYDC196RGTm2jk=
github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4O8IB2ozzxM=
github.com/tencentyun/cos-go-sdk-v5 v0.7.40/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw=
github.com/thanos-io/objstore v0.0.0-20241105144332-b598dceacb13 h1:PQd6xZs18KGoCZJgL9eyYsrRGzzRwYCr4iXuehZm++w=
github.com/thanos-io/objstore v0.0.0-20241105144332-b598dceacb13/go.mod h1:/ZMUxFcp/nT6oYV5WslH9k07NU/+86+aibgZRmMMr/4=
github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97 h1:VjG0mwhN1DkncwDHFvrpd12/2TLfgYNRmEQA48ikp+0=
github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97/go.mod h1:vyzFrBXgP+fGNG2FopEGWOO/zrIuoy7zt3LpLeezRsw=
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
40 changes: 40 additions & 0 deletions pkg/storage/bucket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"errors"
"flag"
"fmt"
"net/http"
"regexp"

"github.com/go-kit/log"
Expand Down Expand Up @@ -126,6 +128,44 @@ func (cfg *Config) Validate() error {
return cfg.StorageBackendConfig.Validate()
}

func (cfg *Config) disableRetries(backend string) error {
switch backend {
case S3:
cfg.S3.MaxRetries = 1
case GCS:
cfg.GCS.MaxRetries = 1
case Azure:
cfg.Azure.MaxRetries = 1
case Swift:
cfg.Swift.MaxRetries = 1
case Filesystem:
// do nothing
default:
return fmt.Errorf("cannot disable retries for backend: %s", backend)
}

return nil
}

func (cfg *Config) configureTransport(backend string, rt http.RoundTripper) error {
switch backend {
case S3:
cfg.S3.HTTP.Transport = rt
case GCS:
cfg.GCS.Transport = rt
case Azure:
cfg.Azure.Transport = rt
case Swift:
cfg.Swift.Transport = rt
case Filesystem:
// do nothing
default:
return fmt.Errorf("cannot configure transport for backend: %s", backend)
}

return nil
}

// NewClient creates a new bucket client based on the configured backend
func NewClient(ctx context.Context, backend string, cfg Config, name string, logger log.Logger) (objstore.InstrumentedBucket, error) {
var (
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/bucket/gcs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
BucketName string `yaml:"bucket_name"`
ServiceAccount flagext.Secret `yaml:"service_account" doc:"description_method=GCSServiceAccountLongDescription"`
ChunkBufferSize int `yaml:"chunk_buffer_size"`
MaxRetries int `yaml:"max_retries"`

// Allow upstream callers to inject a round tripper
Transport http.RoundTripper `yaml:"-"`
Expand All @@ -27,6 +28,7 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.StringVar(&cfg.BucketName, prefix+"gcs.bucket-name", "", "GCS bucket name")
f.Var(&cfg.ServiceAccount, prefix+"gcs.service-account", cfg.GCSServiceAccountShortDescription())
f.IntVar(&cfg.ChunkBufferSize, prefix+"gcs.chunk-buffer-size", 0, "The maximum size of the buffer that GCS client for a single PUT request. 0 to disable buffering.")
f.IntVar(&cfg.MaxRetries, prefix+"gcs.max-retries", 10, "The maximum number of retries for idempotent operations. Overrides the default gcs storage client behavior if this value is greater than 0. Set this to 1 to disable retries.")
}

func (cfg *Config) GCSServiceAccountShortDescription() string {
Expand Down
30 changes: 8 additions & 22 deletions pkg/storage/bucket/object_client_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"net/http"
"slices"
"strings"

Expand All @@ -28,6 +27,12 @@ type ObjectClientAdapter struct {
}

func NewObjectClient(ctx context.Context, backend string, cfg Config, component string, hedgingCfg hedging.Config, disableRetries bool, logger log.Logger) (*ObjectClientAdapter, error) {
if disableRetries {
if err := cfg.disableRetries(backend); err != nil {
return nil, fmt.Errorf("create bucket: %w", err)
}
}

bucket, err := NewClient(ctx, backend, cfg, component, logger)
if err != nil {
return nil, fmt.Errorf("create bucket: %w", err)
Expand All @@ -40,8 +45,8 @@ func NewObjectClient(ctx context.Context, backend string, cfg Config, component
return nil, fmt.Errorf("create hedged transport: %w", err)
}

if err := configureTransport(backend, hedgedTrasport, &cfg); err != nil {
return nil, err
if err := cfg.configureTransport(backend, hedgedTrasport); err != nil {
return nil, fmt.Errorf("create hedged bucket: %w", err)
}

bucket, err = NewClient(ctx, backend, cfg, component, logger)
Expand Down Expand Up @@ -71,25 +76,6 @@ func NewObjectClient(ctx context.Context, backend string, cfg Config, component
return o, nil
}

func configureTransport(backend string, rt http.RoundTripper, cfg *Config) error {
switch backend {
case S3:
cfg.S3.HTTP.Transport = rt
case GCS:
cfg.GCS.Transport = rt
case Azure:
cfg.Azure.Transport = rt
case Swift:
cfg.Swift.Transport = rt
case Filesystem:
// do nothing
default:
return fmt.Errorf("hedging not supported for backend: %s", backend)
}

return nil
}

func (o *ObjectClientAdapter) Stop() {
}

Expand Down
1 change: 1 addition & 0 deletions pkg/storage/bucket/s3/bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ func newS3Config(cfg Config) (s3.Config, error) {
Enable: cfg.TraceConfig.Enabled,
},
STSEndpoint: cfg.STSEndpoint,
MaxRetries: cfg.MaxRetries,
}, nil
}
2 changes: 2 additions & 0 deletions pkg/storage/bucket/s3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type Config struct {
PartSize uint64 `yaml:"part_size" category:"experimental"`
SendContentMd5 bool `yaml:"send_content_md5" category:"experimental"`
STSEndpoint string `yaml:"sts_endpoint"`
MaxRetries int `yaml:"max_retries"`

SSE SSEConfig `yaml:"sse"`
HTTP HTTPConfig `yaml:"http"`
Expand Down Expand Up @@ -146,6 +147,7 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.Var(newBucketLookupTypeValue(s3.AutoLookup, &cfg.BucketLookupType), prefix+"s3.bucket-lookup-type", fmt.Sprintf("Bucket lookup style type, used to access bucket in S3-compatible service. Default is auto. Supported values are: %s.", strings.Join(supportedBucketLookupTypes, ", ")))
f.BoolVar(&cfg.DualstackEnabled, prefix+"s3.dualstack-enabled", true, "When enabled, direct all AWS S3 requests to the dual-stack IPv4/IPv6 endpoint for the configured region.")
f.StringVar(&cfg.STSEndpoint, prefix+"s3.sts-endpoint", "", "Accessing S3 resources using temporary, secure credentials provided by AWS Security Token Service.")
f.IntVar(&cfg.MaxRetries, prefix+"s3.max-retries", 10, "The maximum number of retries for S3 requests that are retryable. Default is 10, set this to 1 to disable retries.")
cfg.SSE.RegisterFlagsWithPrefix(prefix+"s3.sse.", f)
cfg.HTTP.RegisterFlagsWithPrefix(prefix, f)
cfg.TraceConfig.RegisterFlagsWithPrefix(prefix+"s3.trace.", f)
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/thanos-io/objstore/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/thanos-io/objstore/providers/gcs/gcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/thanos-io/objstore/providers/s3/s3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1582,8 +1582,8 @@ github.com/stretchr/testify/assert
github.com/stretchr/testify/mock
github.com/stretchr/testify/require
github.com/stretchr/testify/suite
# github.com/thanos-io/objstore v0.0.0-20241105144332-b598dceacb13
## explicit; go 1.21
# github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97
## explicit; go 1.22
github.com/thanos-io/objstore
github.com/thanos-io/objstore/exthttp
github.com/thanos-io/objstore/providers/azure
Expand Down
Loading