Skip to content

Commit 0329b52

Browse files
committed
Feat: Add support to store tokens in rulers
1 parent e6a4e49 commit 0329b52

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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)