Skip to content

Commit 7e07d24

Browse files
authored
rulers: Add support to persist tokens in rulers (#5987)
* Feat: Add support to store tokens in rulers Signed-off-by: Raphael Silva <[email protected]> * Add changelog Signed-off-by: Raphael Silva <[email protected]> * Add new flag to v1 guarantees documentation Signed-off-by: Raphael Silva <[email protected]> * Fix lint error in documentation Signed-off-by: Raphael Silva <[email protected]> * Make changelog consistent with convention Signed-off-by: Raphael Silva <[email protected]> * Fix lint error in documentation Signed-off-by: Raphael Silva <[email protected]> --------- Signed-off-by: Raphael Silva <[email protected]>
1 parent d56c7e4 commit 7e07d24

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Changelog
22

33
## master / unreleased
4-
54
* [CHANGE] Upgrade Dockerfile Node version from 14x to 18x. #5906
65
* [CHANGE] Ingester: Remove `-querier.query-store-for-labels-enabled` flag. Querying long-term store for labels is always enabled. #5984
6+
* [ENHANCEMENT] rulers: Add support to persist tokens in rulers. #5987
77
* [ENHANCEMENT] Query Frontend/Querier: Added store gateway postings touched count and touched size in Querier stats and log in Query Frontend. #5892
88
* [ENHANCEMENT] Query Frontend/Querier: Returns `warnings` on prometheus query responses. #5916
99
* [ENHANCEMENT] Ingester: Allowing to configure `-blocks-storage.tsdb.head-compaction-interval` flag up to 30 min and add a jitter on the first head compaction. #5919 #5928

docs/configuration/config-file-reference.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,6 +4262,11 @@ ring:
42624262
# CLI flag: -ruler.ring.zone-awareness-enabled
42634263
[zone_awareness_enabled: <boolean> | default = false]
42644264
4265+
# EXPERIMENTAL: File path where tokens are stored. If empty, tokens are not
4266+
# stored at shutdown and restored at startup.
4267+
# CLI flag: -ruler.ring.tokens-file-path
4268+
[tokens_file_path: <string> | default = ""]
4269+
42654270
# Name of network interface to read address from.
42664271
# CLI flag: -ruler.ring.instance-interface-names
42674272
[instance_interface_names: <list of string> | default = [eth0 en0]]

docs/configuration/v1-guarantees.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ Currently experimental features are:
109109
- `store-gateway.sharding-ring.final-sleep` (duration) CLI flag
110110
- `alertmanager-sharding-ring.final-sleep` (duration) CLI flag
111111
- OTLP Receiver
112+
- Persistent tokens in the Ruler Ring:
113+
- `-ruler.ring.tokens-file-path` (path) CLI flag

pkg/ruler/ruler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ func enableSharding(r *Ruler, ringStore kv.Client) error {
372372
// chained via "next delegate").
373373
delegate := ring.BasicLifecyclerDelegate(r)
374374
delegate = ring.NewLeaveOnStoppingDelegate(delegate, r.logger)
375+
delegate = ring.NewTokensPersistencyDelegate(r.cfg.Ring.TokensFilePath, ring.JOINING, delegate, r.logger)
375376
delegate = ring.NewAutoForgetDelegate(r.cfg.Ring.HeartbeatTimeout*ringAutoForgetUnhealthyPeriods, delegate, r.logger)
376377

377378
rulerRingName := "ruler"

pkg/ruler/ruler_ring.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type RingConfig struct {
4343
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
4444
ReplicationFactor int `yaml:"replication_factor"`
4545
ZoneAwarenessEnabled bool `yaml:"zone_awareness_enabled"`
46+
TokensFilePath string `yaml:"tokens_file_path"`
4647

4748
// Instance details
4849
InstanceID string `yaml:"instance_id" doc:"hidden"`
@@ -75,6 +76,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
7576
f.DurationVar(&cfg.FinalSleep, "ruler.ring.final-sleep", 0*time.Second, "The sleep seconds when ruler is shutting down. Need to be close to or larger than KV Store information propagation delay")
7677
f.IntVar(&cfg.ReplicationFactor, "ruler.ring.replication-factor", 1, "EXPERIMENTAL: The replication factor to use when loading rule groups for API HA.")
7778
f.BoolVar(&cfg.ZoneAwarenessEnabled, "ruler.ring.zone-awareness-enabled", false, "EXPERIMENTAL: True to enable zone-awareness and load rule groups across different availability zones for API HA.")
79+
f.StringVar(&cfg.TokensFilePath, "ruler.ring.tokens-file-path", "", "EXPERIMENTAL: File path where tokens are stored. If empty, tokens are not stored at shutdown and restored at startup.")
7880

7981
// Instance flags
8082
cfg.InstanceInterfaceNames = []string{"eth0", "en0"}

0 commit comments

Comments
 (0)