diff --git a/cmd/thanos/store.go b/cmd/thanos/store.go index 9ad3960ff5..cb0160445e 100644 --- a/cmd/thanos/store.go +++ b/cmd/thanos/store.go @@ -309,7 +309,7 @@ func runStore( r := route.New() if len(cachingBucketConfigYaml) > 0 { - insBkt, err = storecache.NewCachingBucketFromYaml(cachingBucketConfigYaml, insBkt, logger, reg, r) + insBkt, err = storecache.NewCachingBucketFromYaml(cachingBucketConfigYaml, insBkt, logger, reg, r, conf.cachingBucketConfig.Path()) if err != nil { return errors.Wrap(err, "create caching bucket") } diff --git a/pkg/store/cache/caching_bucket_factory.go b/pkg/store/cache/caching_bucket_factory.go index 18abc90af3..99db3132b9 100644 --- a/pkg/store/cache/caching_bucket_factory.go +++ b/pkg/store/cache/caching_bucket_factory.go @@ -74,7 +74,7 @@ func (cfg *CachingWithBackendConfig) Defaults() { } // NewCachingBucketFromYaml uses YAML configuration to create new caching bucket. -func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger log.Logger, reg prometheus.Registerer, r *route.Router) (objstore.InstrumentedBucket, error) { +func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger log.Logger, reg prometheus.Registerer, r *route.Router, configPath string) (objstore.InstrumentedBucket, error) { level.Info(logger).Log("msg", "loading caching bucket configuration") config := &CachingWithBackendConfig{} @@ -84,7 +84,11 @@ func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger return nil, errors.Wrap(err, "parsing config YAML file") } - cfgHash := string(fmt.Sprintf("%d", xxhash.Sum64(yamlContent))) + // Append the config path to the YAML content. This allows + // using identical config with multiple instances. + // TODO(GiedriusS): in the long-term add some kind of "name" + // identifier for each instance. + cfgHash := string(fmt.Sprintf("%d", xxhash.Sum64(append(yamlContent, []byte(configPath)...)))) backendConfig, err := yaml.Marshal(config.BackendConfig) if err != nil {