Skip to content

Commit

Permalink
Add note about call change and implement listv2 for s3
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Jul 27, 2023
1 parent c1ab0d7 commit 2672fbe
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,27 @@ func (rw *readerWriter) ListBlocks(_ context.Context, keypath backend.KeyPath) (
prefix = prefix + "/"
}

nextMarker := ""
nextToken := ""
isTruncated := true
var parts []string
var id uuid.UUID
var res minio.ListBucketResult
var res minio.ListBucketV2Result

for isTruncated {
res, err = rw.core.ListObjects(rw.cfg.Bucket, prefix, nextMarker, ".json", 0)
// The "n" delimter here is used to identify files that end with "n", which
// will yield json files.
res, err = rw.core.ListObjectsV2(rw.cfg.Bucket, prefix, "", nextToken, "n", 0)
if err != nil {
return nil, nil, errors.Wrapf(err, "error listing blocks in s3 bucket, bucket: %s", rw.cfg.Bucket)
}

// level.Debug(s.logger).Log("response", spew.Sdump(res))

isTruncated = res.IsTruncated
nextMarker = res.NextMarker
nextToken = res.NextContinuationToken

level.Debug(rw.logger).Log("msg", "block list", "keypath", path.Join(keypath...)+"/",
"found", len(res.CommonPrefixes), "IsTruncated", res.IsTruncated, "NextMarker", res.NextMarker)
"found", len(res.CommonPrefixes), "IsTruncated", res.IsTruncated, "NextMarker", res.NextContinuationToken)

if len(res.CommonPrefixes) > 0 {
for _, cp := range res.CommonPrefixes {
Expand All @@ -328,7 +330,6 @@ func (rw *readerWriter) ListBlocks(_ context.Context, keypath backend.KeyPath) (
}
}
}

}

level.Debug(rw.logger).
Expand Down

0 comments on commit 2672fbe

Please sign in to comment.