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

Enhancement: Make s3 backend readError logic more robust #905

Merged
merged 9 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [BUGFIX] Cortex upgrade to fix an issue where unhealthy compactors can't be forgotten [#878](https://github.com/grafana/tempo/pull/878) (@joe-elliott)
* [ENHANCEMENT] Added "query blocks" cli option. [#876](https://github.com/grafana/tempo/pull/876) (@joe-elliott)
* [ENHANCEMENT] Added traceid to `trace too large message`. [#888](https://github.com/grafana/tempo/pull/888) (@mritunjaysharma394)
* [ENHANCEMENT] Make s3 backend readError logic more robust [#905](https://github.com/grafana/tempo/pull/905) (@wei840222)
* [ENHANCEMENT] Add support to tempo workloads to `overrides` from single configmap in microservice mode. [#896](https://github.com/grafana/tempo/pull/896) (@kavirajk)

## v1.1.0-rc.0 / 2021-08-11
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/Azure/azure-pipeline-go v0.2.2
github.com/Azure/azure-storage-blob-go v0.8.0
github.com/alecthomas/kong v0.2.11
github.com/aws/aws-sdk-go v1.38.60
github.com/cespare/xxhash v1.1.0
github.com/cortexproject/cortex v1.10.1-0.20210816080356-090988c40f3e
github.com/cristalhq/hedgedhttp v0.6.0
Expand Down
7 changes: 3 additions & 4 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/grafana/tempo/tempodb/backend/instrumentation"

"github.com/aws/aws-sdk-go/service/s3"
log_util "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cristalhq/hedgedhttp"
"github.com/go-kit/kit/log"
Expand All @@ -26,7 +27,6 @@ import (
)

const (
s3KeyDoesNotExist = "The specified key does not exist."
uptoHedgedRequests = 2
)

Expand Down Expand Up @@ -262,7 +262,7 @@ func (rw *readerWriter) readAll(ctx context.Context, name string) ([]byte, error

func (rw *readerWriter) readAllWithObjInfo(ctx context.Context, name string) ([]byte, minio.ObjectInfo, error) {
reader, info, _, err := rw.hedgedCore.GetObject(ctx, rw.cfg.Bucket, name, minio.GetObjectOptions{})
if err != nil && err.Error() == s3KeyDoesNotExist {
if err != nil && minio.ToErrorResponse(err).Code == s3.ErrCodeNoSuchKey {
return nil, minio.ObjectInfo{}, backend.ErrDoesNotExist
} else if err != nil {
return nil, minio.ObjectInfo{}, errors.Wrap(err, "error fetching object from s3 backend")
Expand Down Expand Up @@ -359,9 +359,8 @@ func createCore(cfg *Config, hedge bool) (*minio.Core, error) {
}

func readError(err error) error {
if err != nil && err.Error() == s3KeyDoesNotExist {
if err != nil && minio.ToErrorResponse(err).Code == s3.ErrCodeNoSuchKey {
return backend.ErrDoesNotExist
}

return err
}
6 changes: 5 additions & 1 deletion tempodb/backend/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
"testing"
"time"

"github.com/aws/aws-sdk-go/service/s3"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/grafana/tempo/tempodb/backend"
"github.com/minio/minio-go/v7"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -103,7 +105,9 @@ func fakeServer(t *testing.T, returnIn time.Duration, counter *int32) *httptest.
}

func TestReadError(t *testing.T) {
errA := fmt.Errorf(s3KeyDoesNotExist)
errA := minio.ErrorResponse{
Code: s3.ErrCodeNoSuchKey,
}
errB := readError(errA)
assert.Equal(t, backend.ErrDoesNotExist, errB)

Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ github.com/armon/go-metrics/prometheus
# github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef
github.com/asaskevich/govalidator
# github.com/aws/aws-sdk-go v1.38.60
## explicit
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/arn
github.com/aws/aws-sdk-go/aws/awserr
Expand Down