Skip to content

Commit eac2822

Browse files
committed
allow compactor unregisteronshutdown to be configurable
Signed-off-by: Wen Xu <[email protected]>
1 parent 9ad4e90 commit eac2822

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/compactor/compactor_ring.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type RingConfig struct {
3232
InstancePort int `yaml:"instance_port" doc:"hidden"`
3333
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`
3434
TokensFilePath string `yaml:"tokens_file_path"`
35+
UnregisterOnShutdown bool `yaml:"unregister_on_shutdown"`
3536

3637
// Injected internally
3738
ListenPort int `yaml:"-"`
@@ -65,6 +66,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
6566
f.IntVar(&cfg.InstancePort, "compactor.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
6667
f.StringVar(&cfg.InstanceID, "compactor.ring.instance-id", hostname, "Instance ID to register in the ring.")
6768
f.StringVar(&cfg.TokensFilePath, "compactor.ring.tokens-file-path", "", "File path where tokens are stored. If empty, tokens are not stored at shutdown and restored at startup.")
69+
f.BoolVar(&cfg.UnregisterOnShutdown, "compactor.ring.unregister-on-shutdown", true, "Unregister the compactor during shutdown if true.")
6870

6971
// Timeout durations
7072
f.DurationVar(&cfg.WaitActiveInstanceTimeout, "compactor.ring.wait-active-instance-timeout", 10*time.Minute, "Timeout for waiting on compactor to become ACTIVE in the ring.")
@@ -94,7 +96,7 @@ func (cfg *RingConfig) ToLifecyclerConfig() ring.LifecyclerConfig {
9496
lc.Port = cfg.InstancePort
9597
lc.ID = cfg.InstanceID
9698
lc.InfNames = cfg.InstanceInterfaceNames
97-
lc.UnregisterOnShutdown = true
99+
lc.UnregisterOnShutdown = cfg.UnregisterOnShutdown
98100
lc.HeartbeatPeriod = cfg.HeartbeatPeriod
99101
lc.ObservePeriod = cfg.ObservePeriod
100102
lc.JoinAfter = 0

0 commit comments

Comments
 (0)