From d7f002c754a9bb241d7136e3394f40b6667e08b0 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Mon, 1 Apr 2024 20:55:42 +0200 Subject: [PATCH] Do not cache list operations in tests where config is created as literal Signed-off-by: Christian Haudum --- pkg/storage/stores/shipper/bloomshipper/config/config.go | 7 +++++++ pkg/storage/stores/shipper/bloomshipper/store.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/storage/stores/shipper/bloomshipper/config/config.go b/pkg/storage/stores/shipper/bloomshipper/config/config.go index 3aef86cabdf22..08a80f1f49b4c 100644 --- a/pkg/storage/stores/shipper/bloomshipper/config/config.go +++ b/pkg/storage/stores/shipper/bloomshipper/config/config.go @@ -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 { @@ -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 { diff --git a/pkg/storage/stores/shipper/bloomshipper/store.go b/pkg/storage/stores/shipper/bloomshipper/store.go index 7fff40fcc594f..e9147e4711b0c 100644 --- a/pkg/storage/stores/shipper/bloomshipper/store.go +++ b/pkg/storage/stores/shipper/bloomshipper/store.go @@ -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)