Skip to content

Commit

Permalink
Fix object prefix not being stripped for Dell ECS (#561)
Browse files Browse the repository at this point in the history
* Fix object prefix not being stripped for Dell ECS

This commit ensure that the same object prefix string is used to query and strip
an object when listing all the objects in a bucket.

Some S3 implementations (in this case Dell ECS) cannot be relied upon to return
the correct `res.Prefix`. Dell ECS will return it URLencoded, e.g. "traceID%2F"
instead of "traceID/".

* Add changelog

* Update CHANGELOG.md

Co-authored-by: Graham Reed <greed@7deadly.org>

Co-authored-by: Graham Reed <greed@7deadly.org>
  • Loading branch information
kradalby and greed42 authored Mar 1, 2021
1 parent 194691c commit 60e2722
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* [ENHANCEMENT] Add a Shutdown handler to flush data to backend, at "/shutdown". [#526](https://github.com/grafana/tempo/pull/526)
* [BUGFIX] Fixes permissions errors on startup in GCS. [#554](https://github.com/grafana/tempo/pull/554)
* [BUGFIX] Fixes error where Dell ECS cannot list objects. [#561](https://github.com/grafana/tempo/pull/561)


## v0.6.0

Expand Down
5 changes: 3 additions & 2 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,17 @@ func (rw *readerWriter) Tenants(ctx context.Context) ([]string, error) {

// Blocks implements backend.Reader
func (rw *readerWriter) Blocks(ctx context.Context, tenantID string) ([]uuid.UUID, error) {
prefix := tenantID + "/"
// ListObjects(bucket, prefix, marker, delimiter string, maxKeys int)
res, err := rw.core.ListObjects(rw.cfg.Bucket, tenantID+"/", "", "/", 0)
res, err := rw.core.ListObjects(rw.cfg.Bucket, prefix, "", "/", 0)
if err != nil {
return nil, errors.Wrapf(err, "error listing blocks in s3 bucket, bucket: %s", rw.cfg.Bucket)
}

level.Debug(rw.logger).Log("msg", "listing blocks", "tenantID", tenantID, "found", len(res.CommonPrefixes))
var blockIDs []uuid.UUID
for _, cp := range res.CommonPrefixes {
blockID, err := uuid.Parse(strings.Split(strings.TrimPrefix(cp.Prefix, res.Prefix), "/")[0])
blockID, err := uuid.Parse(strings.Split(strings.TrimPrefix(cp.Prefix, prefix), "/")[0])
if err != nil {
return nil, errors.Wrapf(err, "error parsing uuid of obj, objectName: %s", cp.Prefix)
}
Expand Down

0 comments on commit 60e2722

Please sign in to comment.