Skip to content

Commit bc4d24c

Browse files
authored
Catch context error when getting bucket index (#5935)
* Catch context error when getting bucket index Signed-off-by: Wilbert Guo <[email protected]> * change logger --------- Signed-off-by: Wilbert Guo <[email protected]>
1 parent 09ea351 commit bc4d24c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/storage/tsdb/bucketindex/loader.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/cortexproject/cortex/pkg/storage/bucket"
1717
"github.com/cortexproject/cortex/pkg/util"
18+
util_log "github.com/cortexproject/cortex/pkg/util/log"
1819
"github.com/cortexproject/cortex/pkg/util/services"
1920
)
2021

@@ -92,6 +93,11 @@ func NewLoader(cfg LoaderConfig, bucketClient objstore.Bucket, cfgProvider bucke
9293
// GetIndex returns the bucket index for the given user. It returns the in-memory cached
9394
// index if available, or load it from the bucket otherwise.
9495
func (l *Loader) GetIndex(ctx context.Context, userID string) (*Index, Status, error) {
96+
if ctx.Err() != nil {
97+
level.Warn(util_log.WithContext(ctx, l.logger)).Log("msg", "received context error when attempting to load bucket index", "err", ctx.Err())
98+
return nil, UnknownStatus, ctx.Err()
99+
}
100+
95101
l.indexesMx.RLock()
96102
if entry := l.indexes[userID]; entry != nil {
97103
idx := entry.index

0 commit comments

Comments
 (0)