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
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
11 changes: 9 additions & 2 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
)

const (
s3KeyDoesNotExist = "The specified key does not exist."
uptoHedgedRequests = 2
s3KeyDoesNotExist = "The specified key does not exist."
s3KeyDoesNotExistCode = "NoSuchKey"
wei840222 marked this conversation as resolved.
Show resolved Hide resolved
uptoHedgedRequests = 2
)

// readerWriter can read/write from an s3 backend
Expand Down Expand Up @@ -264,6 +265,8 @@ func (rw *readerWriter) readAllWithObjInfo(ctx context.Context, name string) ([]
reader, info, _, err := rw.hedgedCore.GetObject(ctx, rw.cfg.Bucket, name, minio.GetObjectOptions{})
if err != nil && err.Error() == s3KeyDoesNotExist {
return nil, minio.ObjectInfo{}, backend.ErrDoesNotExist
} else if err != nil && minio.ToErrorResponse(err).Code == s3KeyDoesNotExistCode {
mapno marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -363,5 +366,9 @@ func readError(err error) error {
return backend.ErrDoesNotExist
}

if err != nil && minio.ToErrorResponse(err).Code == s3KeyDoesNotExistCode {
return backend.ErrDoesNotExist
}

return err
}