Skip to content

Commit d443d80

Browse files
committed
removing redundant config
Signed-off-by: alanprot <[email protected]>
1 parent d8d226d commit d443d80

File tree

6 files changed

+36
-69
lines changed

6 files changed

+36
-69
lines changed

docs/blocks-storage/querier.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,28 +1550,20 @@ blocks_storage:
15501550
# compacted blocks.
15511551
expanded_postings_cache:
15521552
head:
1553+
# TTL for postings cache, 0 to disable.
1554+
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
1555+
[ttl: <duration> | default = 0s]
1556+
15531557
# Max bytes for postings cache
15541558
# CLI flag: -blocks-storage.expanded_postings_cache.head.max-bytes
15551559
[max_bytes: <int> | default = 10485760]
15561560

1557-
# TTL for postings cache
1558-
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
1559-
[ttl: <duration> | default = 10m]
1560-
1561-
# Whether the postings cache is enabled or not
1562-
# CLI flag: -blocks-storage.expanded_postings_cache.head.enabled
1563-
[enabled: <boolean> | default = false]
1564-
15651561
blocks:
1562+
# TTL for postings cache, 0 to disable.
1563+
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
1564+
[ttl: <duration> | default = 0s]
1565+
15661566
# Max bytes for postings cache
15671567
# CLI flag: -blocks-storage.expanded_postings_cache.block.max-bytes
15681568
[max_bytes: <int> | default = 10485760]
1569-
1570-
# TTL for postings cache
1571-
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
1572-
[ttl: <duration> | default = 10m]
1573-
1574-
# Whether the postings cache is enabled or not
1575-
# CLI flag: -blocks-storage.expanded_postings_cache.block.enabled
1576-
[enabled: <boolean> | default = false]
15771569
```

docs/blocks-storage/store-gateway.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,28 +1641,20 @@ blocks_storage:
16411641
# compacted blocks.
16421642
expanded_postings_cache:
16431643
head:
1644+
# TTL for postings cache, 0 to disable.
1645+
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
1646+
[ttl: <duration> | default = 0s]
1647+
16441648
# Max bytes for postings cache
16451649
# CLI flag: -blocks-storage.expanded_postings_cache.head.max-bytes
16461650
[max_bytes: <int> | default = 10485760]
16471651

1648-
# TTL for postings cache
1649-
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
1650-
[ttl: <duration> | default = 10m]
1651-
1652-
# Whether the postings cache is enabled or not
1653-
# CLI flag: -blocks-storage.expanded_postings_cache.head.enabled
1654-
[enabled: <boolean> | default = false]
1655-
16561652
blocks:
1653+
# TTL for postings cache, 0 to disable.
1654+
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
1655+
[ttl: <duration> | default = 0s]
1656+
16571657
# Max bytes for postings cache
16581658
# CLI flag: -blocks-storage.expanded_postings_cache.block.max-bytes
16591659
[max_bytes: <int> | default = 10485760]
1660-
1661-
# TTL for postings cache
1662-
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
1663-
[ttl: <duration> | default = 10m]
1664-
1665-
# Whether the postings cache is enabled or not
1666-
# CLI flag: -blocks-storage.expanded_postings_cache.block.enabled
1667-
[enabled: <boolean> | default = false]
16681660
```

docs/configuration/config-file-reference.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,30 +2087,22 @@ tsdb:
20872087
# compacted blocks.
20882088
expanded_postings_cache:
20892089
head:
2090+
# TTL for postings cache, 0 to disable.
2091+
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
2092+
[ttl: <duration> | default = 0s]
2093+
20902094
# Max bytes for postings cache
20912095
# CLI flag: -blocks-storage.expanded_postings_cache.head.max-bytes
20922096
[max_bytes: <int> | default = 10485760]
20932097

2094-
# TTL for postings cache
2095-
# CLI flag: -blocks-storage.expanded_postings_cache.head.ttl
2096-
[ttl: <duration> | default = 10m]
2097-
2098-
# Whether the postings cache is enabled or not
2099-
# CLI flag: -blocks-storage.expanded_postings_cache.head.enabled
2100-
[enabled: <boolean> | default = false]
2101-
21022098
blocks:
2099+
# TTL for postings cache, 0 to disable.
2100+
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
2101+
[ttl: <duration> | default = 0s]
2102+
21032103
# Max bytes for postings cache
21042104
# CLI flag: -blocks-storage.expanded_postings_cache.block.max-bytes
21052105
[max_bytes: <int> | default = 10485760]
2106-
2107-
# TTL for postings cache
2108-
# CLI flag: -blocks-storage.expanded_postings_cache.block.ttl
2109-
[ttl: <duration> | default = 10m]
2110-
2111-
# Whether the postings cache is enabled or not
2112-
# CLI flag: -blocks-storage.expanded_postings_cache.block.enabled
2113-
[enabled: <boolean> | default = false]
21142106
```
21152107
21162108
### `compactor_config`

pkg/ingester/ingester.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registe
711711
i.ingestionRate,
712712
&i.inflightPushRequests,
713713
&i.maxInflightQueryRequests,
714-
cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled || cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled)
714+
cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled() || cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled())
715715
i.validateMetrics = validation.NewValidateMetrics(registerer)
716716

717717
// Replace specific metrics which we can't directly track but we need to read
@@ -793,7 +793,7 @@ func NewForFlusher(cfg Config, limits *validation.Overrides, registerer promethe
793793
nil,
794794
&i.inflightPushRequests,
795795
&i.maxInflightQueryRequests,
796-
cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled || cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled,
796+
cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled() || cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled(),
797797
)
798798

799799
i.TSDBState.shipperIngesterID = "flusher"
@@ -2174,7 +2174,7 @@ func (i *Ingester) createTSDB(userID string) (*userTSDB, error) {
21742174
blockRanges := i.cfg.BlocksStorageConfig.TSDB.BlockRanges.ToMilliseconds()
21752175

21762176
var postingCache cortex_tsdb.ExpandedPostingsCache
2177-
if i.cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled || i.cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled {
2177+
if i.cfg.BlocksStorageConfig.TSDB.PostingsCache.Head.Enabled() || i.cfg.BlocksStorageConfig.TSDB.PostingsCache.Blocks.Enabled() {
21782178
logutil.WarnExperimentalUse("expanded postings cache")
21792179
postingCache = cortex_tsdb.NewBlocksPostingsForMatchersCache(i.cfg.BlocksStorageConfig.TSDB.PostingsCache, i.metrics.expandedPostingsCacheMetrics)
21802180
}

pkg/ingester/ingester_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,14 +5104,7 @@ func TestExpendedPostingsCache(t *testing.T) {
51045104
"cacheDisabled": {
51055105
expectedBlockPostingCall: 0,
51065106
expectedHeadPostingCall: 0,
5107-
cacheConfig: cortex_tsdb.TSDBPostingsCacheConfig{
5108-
Head: cortex_tsdb.PostingsCacheConfig{
5109-
Enabled: false,
5110-
},
5111-
Blocks: cortex_tsdb.PostingsCacheConfig{
5112-
Enabled: false,
5113-
},
5114-
},
5107+
cacheConfig: cortex_tsdb.TSDBPostingsCacheConfig{},
51155108
},
51165109
"enabled cache on compacted blocks": {
51175110
expectedBlockPostingCall: 1,
@@ -5120,7 +5113,6 @@ func TestExpendedPostingsCache(t *testing.T) {
51205113
Blocks: cortex_tsdb.PostingsCacheConfig{
51215114
Ttl: time.Hour,
51225115
MaxBytes: 1024 * 1024 * 1024,
5123-
Enabled: true,
51245116
},
51255117
},
51265118
},
@@ -5131,7 +5123,6 @@ func TestExpendedPostingsCache(t *testing.T) {
51315123
Head: cortex_tsdb.PostingsCacheConfig{
51325124
Ttl: time.Hour,
51335125
MaxBytes: 1024 * 1024 * 1024,
5134-
Enabled: true,
51355126
},
51365127
},
51375128
},
@@ -5142,12 +5133,10 @@ func TestExpendedPostingsCache(t *testing.T) {
51425133
Blocks: cortex_tsdb.PostingsCacheConfig{
51435134
Ttl: time.Hour,
51445135
MaxBytes: 1024 * 1024 * 1024,
5145-
Enabled: true,
51465136
},
51475137
Head: cortex_tsdb.PostingsCacheConfig{
51485138
Ttl: time.Hour,
51495139
MaxBytes: 1024 * 1024 * 1024,
5150-
Enabled: true,
51515140
},
51525141
},
51535142
},

pkg/storage/tsdb/expanded_postings_cache.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ type TSDBPostingsCacheConfig struct {
6767
}
6868

6969
type PostingsCacheConfig struct {
70-
MaxBytes int64 `yaml:"max_bytes"`
7170
Ttl time.Duration `yaml:"ttl"`
72-
Enabled bool `yaml:"enabled"`
71+
MaxBytes int64 `yaml:"max_bytes"`
7372
}
7473

7574
func (cfg *TSDBPostingsCacheConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
@@ -80,8 +79,11 @@ func (cfg *TSDBPostingsCacheConfig) RegisterFlagsWithPrefix(prefix string, f *fl
8079
// RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet
8180
func (cfg *PostingsCacheConfig) RegisterFlagsWithPrefix(prefix, block string, f *flag.FlagSet) {
8281
f.Int64Var(&cfg.MaxBytes, prefix+"expanded_postings_cache."+block+".max-bytes", 10*1024*1024, "Max bytes for postings cache")
83-
f.DurationVar(&cfg.Ttl, prefix+"expanded_postings_cache."+block+".ttl", 10*time.Minute, "TTL for postings cache")
84-
f.BoolVar(&cfg.Enabled, prefix+"expanded_postings_cache."+block+".enabled", false, "Whether the postings cache is enabled or not")
82+
f.DurationVar(&cfg.Ttl, prefix+"expanded_postings_cache."+block+".ttl", 0, "TTL for postings cache, 0 to disable.")
83+
}
84+
85+
func (cfg *PostingsCacheConfig) Enabled() bool {
86+
return cfg.Ttl > 0
8587
}
8688

8789
type ExpandedPostingsCache interface {
@@ -160,7 +162,7 @@ func (c *BlocksPostingsForMatchersCache) fetchPostings(blockID ulid.ULID, ix tsd
160162
}
161163

162164
// Let's bypass cache if not enabled
163-
if !cache.cfg.Enabled {
165+
if !cache.cfg.Enabled() {
164166
return func(ctx context.Context) (index.Postings, error) {
165167
return tsdb.PostingsForMatchers(ctx, ix, ms...)
166168
}
@@ -304,7 +306,7 @@ func (c *fifoCache[V]) getPromiseForKey(k string, fetch func() (V, int64, error)
304306
}
305307
defer close(r.done)
306308

307-
if !c.cfg.Enabled {
309+
if !c.cfg.Enabled() {
308310
r.v, _, r.err = fetch()
309311
return r, false
310312
}

0 commit comments

Comments
 (0)