Skip to content

Commit

Permalink
Do not cache list operations in tests where config is created as literal
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Apr 2, 2024
1 parent 9cd84a0 commit d7f002c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/storage/stores/shipper/bloomshipper/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type Config struct {
BlocksDownloadingQueue DownloadingQueueConfig `yaml:"blocks_downloading_queue"`
BlocksCache BlocksCacheConfig `yaml:"blocks_cache"`
MetasCache cache.Config `yaml:"metas_cache"`

// This will always be set to true when flags are registered.
// In tests, where config is created as literal, it can be set manually.
CacheListOps bool `yaml:"-"`
}

type DownloadingQueueConfig struct {
Expand All @@ -37,6 +41,9 @@ func (c *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
c.BlocksDownloadingQueue.RegisterFlagsWithPrefix(prefix+"shipper.blocks-downloading-queue.", f)
c.BlocksCache.RegisterFlagsWithPrefixAndDefaults(prefix+"blocks-cache.", "Cache for bloom blocks. ", f, 24*time.Hour)
c.MetasCache.RegisterFlagsWithPrefix(prefix+"metas-cache.", "Cache for bloom metas. ", f)

// always cache LIST operations
c.CacheListOps = true
}

func (c *Config) Validate() error {
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/stores/shipper/bloomshipper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ func NewBloomStore(
return nil, errors.Wrapf(err, "creating object client for period %s", periodicConfig.From)
}

objectClient = newCachedListOpObjectClient(objectClient, 5*time.Minute, 10*time.Second)
if storageConfig.BloomShipperConfig.CacheListOps {
objectClient = newCachedListOpObjectClient(objectClient, 5*time.Minute, 10*time.Second)
}
bloomClient, err := NewBloomClient(cfg, objectClient, logger)
if err != nil {
return nil, errors.Wrapf(err, "creating bloom client for period %s", periodicConfig.From)
Expand Down

0 comments on commit d7f002c

Please sign in to comment.