Skip to content

Commit

Permalink
allow compactor unregisteronshutdown to be configurable (cortexprojec…
Browse files Browse the repository at this point in the history
…t#5503)

* allow compactor unregisteronshutdown to be configurable

Signed-off-by: Wen Xu <wenxuamz@amazon.com>

* fix lint, add changelog

Signed-off-by: Wen Xu <wenxuamz@amazon.com>

---------

Signed-off-by: Wen Xu <wenxuamz@amazon.com>
  • Loading branch information
wenxu1024 committed Aug 9, 2023
1 parent bf7792e commit 2289baf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* [ENHANCEMENT] Alertmanager: Add the alert name in error log when it get throttled. #5456
* [ENHANCEMENT] Querier: Retry store gateway on different zones when zone awareness is enabled. #5476
* [ENHANCEMENT] DDBKV: Change metric name from dynamodb_kv_read_capacity_total to dynamodb_kv_consumed_capacity_total and include Delete, Put, Batch dimension. #5481
* [ENHANCEMENT] Compactor: allow unregisteronshutdown to be configurable. #5503
* [BUGFIX] Ruler: Validate if rule group can be safely converted back to rule group yaml from protobuf message #5265
* [BUGFIX] Querier: Convert gRPC `ResourceExhausted` status code from store gateway to 422 limit error. #5286
* [BUGFIX] Alertmanager: Route web-ui requests to the alertmanager distributor when sharding is enabled. #5293
Expand Down
4 changes: 4 additions & 0 deletions docs/blocks-storage/compactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ compactor:
# CLI flag: -compactor.ring.tokens-file-path
[tokens_file_path: <string> | default = ""]

# Unregister the compactor during shutdown if true.
# CLI flag: -compactor.ring.unregister-on-shutdown
[unregister_on_shutdown: <boolean> | default = true]

# Timeout for waiting on compactor to become ACTIVE in the ring.
# CLI flag: -compactor.ring.wait-active-instance-timeout
[wait_active_instance_timeout: <duration> | default = 10m]
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration/config-file-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,10 @@ sharding_ring:
# CLI flag: -compactor.ring.tokens-file-path
[tokens_file_path: <string> | default = ""]
# Unregister the compactor during shutdown if true.
# CLI flag: -compactor.ring.unregister-on-shutdown
[unregister_on_shutdown: <boolean> | default = true]
# Timeout for waiting on compactor to become ACTIVE in the ring.
# CLI flag: -compactor.ring.wait-active-instance-timeout
[wait_active_instance_timeout: <duration> | default = 10m]
Expand Down
4 changes: 3 additions & 1 deletion pkg/compactor/compactor_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type RingConfig struct {
InstancePort int `yaml:"instance_port" doc:"hidden"`
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`
TokensFilePath string `yaml:"tokens_file_path"`
UnregisterOnShutdown bool `yaml:"unregister_on_shutdown"`

// Injected internally
ListenPort int `yaml:"-"`
Expand Down Expand Up @@ -65,6 +66,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
f.IntVar(&cfg.InstancePort, "compactor.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
f.StringVar(&cfg.InstanceID, "compactor.ring.instance-id", hostname, "Instance ID to register in the ring.")
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.")
f.BoolVar(&cfg.UnregisterOnShutdown, "compactor.ring.unregister-on-shutdown", true, "Unregister the compactor during shutdown if true.")

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

0 comments on commit 2289baf

Please sign in to comment.