@@ -12,6 +12,7 @@ import (
12
12
"time"
13
13
14
14
"github.com/go-kit/log"
15
+ "github.com/go-kit/log/level"
15
16
"github.com/grafana/dskit/concurrency"
16
17
"github.com/pkg/errors"
17
18
"github.com/prometheus/common/model"
@@ -388,28 +389,34 @@ func (b *BloomClient) GetMetas(ctx context.Context, refs []MetaRef) ([]Meta, err
388
389
err := concurrency .ForEachJob (ctx , len (refs ), b .concurrency , func (ctx context.Context , idx int ) error {
389
390
meta , err := b .GetMeta (ctx , refs [idx ])
390
391
if err != nil {
391
- return err
392
+ key := b .KeyResolver .Meta (refs [idx ]).Addr ()
393
+ if ! b .IsObjectNotFoundErr (err ) {
394
+ return fmt .Errorf ("failed to get meta file %s: %w" , key , err )
395
+ }
396
+ level .Error (b .logger ).Log ("msg" , "failed to get meta file" , "ref" , key , "err" , err )
392
397
}
393
398
results [idx ] = meta
394
399
return nil
395
400
})
396
401
return results , err
397
402
}
398
403
404
+ // GetMeta fetches the meta file for given MetaRef from object storage and
405
+ // decodes the JSON data into a Meta.
406
+ // If the meta file is not found in storage or decoding fails, the empty Meta
407
+ // is returned along with the error.
399
408
func (b * BloomClient ) GetMeta (ctx context.Context , ref MetaRef ) (Meta , error ) {
400
- meta := Meta {
401
- MetaRef : ref ,
402
- }
409
+ meta := Meta {MetaRef : ref }
403
410
key := b .KeyResolver .Meta (ref ).Addr ()
404
411
reader , _ , err := b .client .GetObject (ctx , key )
405
412
if err != nil {
406
- return Meta {}, fmt . Errorf ( "failed to get meta file%s: %w" , key , err )
413
+ return meta , err
407
414
}
408
415
defer reader .Close ()
409
416
410
417
err = json .NewDecoder (reader ).Decode (& meta )
411
418
if err != nil {
412
- return Meta {}, fmt . Errorf ( "failed to decode meta file %s: %w" , key , err )
419
+ return meta , errors . Wrap ( err , "failed to decode JSON" )
413
420
}
414
421
return meta , nil
415
422
}
0 commit comments