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

[Boltdb-shipper] If S3 ListObjects returns the directory itself getDBNameFromObjectKey fails #3173

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions pkg/storage/stores/shipper/compactor/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"

"github.com/cortexproject/cortex/pkg/chunk"
Expand Down Expand Up @@ -107,6 +108,11 @@ func (t *table) compact() error {
return
}

// The s3 client can also return the directory itself in the ListObjects.
if strings.HasSuffix(objectKey, "/") {
continue
}

var dbName string
dbName, err = shipper_util.GetDBNameFromObjectKey(objectKey)
if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions pkg/storage/stores/shipper/downloads/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ func (t *Table) init(ctx context.Context, spanLogger log.Logger) (err error) {

// open all the downloaded dbs
for _, object := range objects {

// The s3 client can also return the directory itself in the ListObjects.
if strings.HasSuffix(object.Key, "/") {
continue
}

dbName, err := getDBNameFromObjectKey(object.Key)
if err != nil {
return err
Expand Down Expand Up @@ -409,6 +415,10 @@ func (t *Table) checkStorageForUpdates(ctx context.Context) (toDownload []chunk.
defer t.dbsMtx.RUnlock()

for _, object := range objects {
// The s3 client can also return the directory itself in the ListObjects.
if strings.HasSuffix(object.Key, "/") {
continue
}
dbName, err := getDBNameFromObjectKey(object.Key)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -506,6 +516,11 @@ func (t *Table) doParallelDownload(ctx context.Context, objects []chunk.StorageO
break
}

// The s3 client can also return the directory itself in the ListObjects.
if strings.HasSuffix(object.Key, "/") {
continue
}

var dbName string
dbName, err = getDBNameFromObjectKey(object.Key)
if err != nil {
Expand Down