Skip to content

Commit 2a1c3c4

Browse files
authored
Enable compactor to use 'TokensFilePath' on ring lifecycler (#5432)
* Enable compactor to use on ring lifecycler Signed-off-by: Daniel Deluiggi <[email protected]> * Add changelog Signed-off-by: Daniel Deluiggi <[email protected]> --------- Signed-off-by: Daniel Deluiggi <[email protected]>
1 parent e55060f commit 2a1c3c4

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [FEATURE] Added the flag `-alertmanager.api-concurrency` to configure alert manager api concurrency limit. #5412
2121
* [FEATURE] Store Gateway: Add `-store-gateway.sharding-ring.keep-instance-in-the-ring-on-shutdown` to skip unregistering instance from the ring in shutdown. #5421
2222
* [FEATURE] Ruler: Support for filtering rules in the API. #5417
23+
* [FEATURE] Compactor: Add `-compactor.ring.tokens-file-path` to store generated tokens locally. #5432
2324
* [ENHANCEMENT] Distributor/Ingester: Add span on push path #5319
2425
* [ENHANCEMENT] Support object storage backends for runtime configuration file. #5292
2526
* [ENHANCEMENT] Query Frontend: Reject subquery with too small step size. #5323

docs/blocks-storage/compactor.md

+5
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ compactor:
268268
# CLI flag: -compactor.ring.instance-interface-names
269269
[instance_interface_names: <list of string> | default = [eth0 en0]]
270270

271+
# File path where tokens are stored. If empty, tokens are not stored at
272+
# shutdown and restored at startup.
273+
# CLI flag: -compactor.ring.tokens-file-path
274+
[tokens_file_path: <string> | default = ""]
275+
271276
# Timeout for waiting on compactor to become ACTIVE in the ring.
272277
# CLI flag: -compactor.ring.wait-active-instance-timeout
273278
[wait_active_instance_timeout: <duration> | default = 10m]

docs/configuration/config-file-reference.md

+5
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,11 @@ sharding_ring:
19421942
# CLI flag: -compactor.ring.instance-interface-names
19431943
[instance_interface_names: <list of string> | default = [eth0 en0]]
19441944
1945+
# File path where tokens are stored. If empty, tokens are not stored at
1946+
# shutdown and restored at startup.
1947+
# CLI flag: -compactor.ring.tokens-file-path
1948+
[tokens_file_path: <string> | default = ""]
1949+
19451950
# Timeout for waiting on compactor to become ACTIVE in the ring.
19461951
# CLI flag: -compactor.ring.wait-active-instance-timeout
19471952
[wait_active_instance_timeout: <duration> | default = 10m]

pkg/compactor/compactor_ring.go

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type RingConfig struct {
3131
InstanceInterfaceNames []string `yaml:"instance_interface_names"`
3232
InstancePort int `yaml:"instance_port" doc:"hidden"`
3333
InstanceAddr string `yaml:"instance_addr" doc:"hidden"`
34+
TokensFilePath string `yaml:"tokens_file_path"`
3435

3536
// Injected internally
3637
ListenPort int `yaml:"-"`
@@ -63,6 +64,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
6364
f.StringVar(&cfg.InstanceAddr, "compactor.ring.instance-addr", "", "IP address to advertise in the ring.")
6465
f.IntVar(&cfg.InstancePort, "compactor.ring.instance-port", 0, "Port to advertise in the ring (defaults to server.grpc-listen-port).")
6566
f.StringVar(&cfg.InstanceID, "compactor.ring.instance-id", hostname, "Instance ID to register in the ring.")
67+
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.")
6668

6769
// Timeout durations
6870
f.DurationVar(&cfg.WaitActiveInstanceTimeout, "compactor.ring.wait-active-instance-timeout", 10*time.Minute, "Timeout for waiting on compactor to become ACTIVE in the ring.")
@@ -98,6 +100,7 @@ func (cfg *RingConfig) ToLifecyclerConfig() ring.LifecyclerConfig {
98100
lc.JoinAfter = 0
99101
lc.MinReadyDuration = 0
100102
lc.FinalSleep = 0
103+
lc.TokensFilePath = cfg.TokensFilePath
101104

102105
// We use a safe default instead of exposing to config option to the user
103106
// in order to simplify the config.

pkg/compactor/compactor_ring_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestRingConfig_CustomConfigToLifecyclerConfig(t *testing.T) {
4141
cfg.InstancePort = 10
4242
cfg.InstanceAddr = "1.2.3.4"
4343
cfg.ListenPort = 10
44+
cfg.TokensFilePath = "testFilePath"
4445

4546
// The lifecycler config should be generated based upon the compactor
4647
// ring config
@@ -52,6 +53,7 @@ func TestRingConfig_CustomConfigToLifecyclerConfig(t *testing.T) {
5253
expected.Port = cfg.InstancePort
5354
expected.Addr = cfg.InstanceAddr
5455
expected.ListenPort = cfg.ListenPort
56+
expected.TokensFilePath = cfg.TokensFilePath
5557

5658
// Hardcoded config
5759
expected.RingConfig.ReplicationFactor = 1

0 commit comments

Comments
 (0)