Skip to content

Commit 852284e

Browse files
committed
Expose KeepInstanceInTheRingOnShutdown config for store gateway
Signed-off-by: Justin Jung <[email protected]>
1 parent 6dd44ee commit 852284e

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* [FEATURE] Querier: Log query stats when querying store gateway. #5376
1818
* [FEATURE] Querier/StoreGateway: Allow the tenant shard sizes to be a percent of total instances. #5393
1919
* [FEATURE] Added the flag `-alertmanager.api-concurrency` to configure alert manager api concurrency limit. #5412
20+
* [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
2021
* [ENHANCEMENT] Distributor/Ingester: Add span on push path #5319
2122
* [ENHANCEMENT] Support object storage backends for runtime configuration file. #5292
2223
* [ENHANCEMENT] Query Frontend: Reject subquery with too small step size. #5323

docs/blocks-storage/store-gateway.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ store_gateway:
282282
# CLI flag: -store-gateway.sharding-ring.zone-awareness-enabled
283283
[zone_awareness_enabled: <boolean> | default = false]
284284

285+
# True to keep the store gateway instance in the ring when it shuts down.
286+
# The instance will then be auto-forgotten from the ring after
287+
# 10*heartbeat_timeout.
288+
# CLI flag: -store-gateway.sharding-ring.keep-instance-in-the-ring-on-shutdown
289+
[keep_instance_in_the_ring_on_shutdown: <boolean> | default = false]
290+
285291
# Minimum time to wait for ring stability at startup. 0 to disable.
286292
# CLI flag: -store-gateway.sharding-ring.wait-stability-min-duration
287293
[wait_stability_min_duration: <duration> | default = 1m]

docs/configuration/config-file-reference.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,6 +4801,12 @@ sharding_ring:
48014801
# CLI flag: -store-gateway.sharding-ring.zone-awareness-enabled
48024802
[zone_awareness_enabled: <boolean> | default = false]
48034803
4804+
# True to keep the store gateway instance in the ring when it shuts down. The
4805+
# instance will then be auto-forgotten from the ring after
4806+
# 10*heartbeat_timeout.
4807+
# CLI flag: -store-gateway.sharding-ring.keep-instance-in-the-ring-on-shutdown
4808+
[keep_instance_in_the_ring_on_shutdown: <boolean> | default = false]
4809+
48044810
# Minimum time to wait for ring stability at startup. 0 to disable.
48054811
# CLI flag: -store-gateway.sharding-ring.wait-stability-min-duration
48064812
[wait_stability_min_duration: <duration> | default = 1m]

pkg/storegateway/gateway_ring.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ var (
6060
// is used to strip down the config to the minimum, and avoid confusion
6161
// to the user.
6262
type RingConfig struct {
63-
KVStore kv.Config `yaml:"kvstore" doc:"description=The key-value store used to share the hash ring across multiple instances. This option needs be set both on the store-gateway and querier when running in microservices mode."`
64-
HeartbeatPeriod time.Duration `yaml:"heartbeat_period"`
65-
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
66-
ReplicationFactor int `yaml:"replication_factor"`
67-
TokensFilePath string `yaml:"tokens_file_path"`
68-
ZoneAwarenessEnabled bool `yaml:"zone_awareness_enabled"`
63+
KVStore kv.Config `yaml:"kvstore" doc:"description=The key-value store used to share the hash ring across multiple instances. This option needs be set both on the store-gateway and querier when running in microservices mode."`
64+
HeartbeatPeriod time.Duration `yaml:"heartbeat_period"`
65+
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
66+
ReplicationFactor int `yaml:"replication_factor"`
67+
TokensFilePath string `yaml:"tokens_file_path"`
68+
ZoneAwarenessEnabled bool `yaml:"zone_awareness_enabled"`
69+
KeepInstanceInTheRingOnShutdown bool `yaml:"keep_instance_in_the_ring_on_shutdown"`
6970

7071
// Wait ring stability.
7172
WaitStabilityMinDuration time.Duration `yaml:"wait_stability_min_duration"`
@@ -100,6 +101,7 @@ func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet) {
100101
f.IntVar(&cfg.ReplicationFactor, ringFlagsPrefix+"replication-factor", 3, "The replication factor to use when sharding blocks."+sharedOptionWithQuerier)
101102
f.StringVar(&cfg.TokensFilePath, ringFlagsPrefix+"tokens-file-path", "", "File path where tokens are stored. If empty, tokens are not stored at shutdown and restored at startup.")
102103
f.BoolVar(&cfg.ZoneAwarenessEnabled, ringFlagsPrefix+"zone-awareness-enabled", false, "True to enable zone-awareness and replicate blocks across different availability zones.")
104+
f.BoolVar(&cfg.KeepInstanceInTheRingOnShutdown, ringFlagsPrefix+"keep-instance-in-the-ring-on-shutdown", false, "True to keep the store gateway instance in the ring when it shuts down. The instance will then be auto-forgotten from the ring after 10*heartbeat_timeout.")
103105

104106
// Wait stability flags.
105107
f.DurationVar(&cfg.WaitStabilityMinDuration, ringFlagsPrefix+"wait-stability-min-duration", time.Minute, "Minimum time to wait for ring stability at startup. 0 to disable.")
@@ -139,11 +141,12 @@ func (cfg *RingConfig) ToLifecyclerConfig(logger log.Logger) (ring.BasicLifecycl
139141
instancePort := ring.GetInstancePort(cfg.InstancePort, cfg.ListenPort)
140142

141143
return ring.BasicLifecyclerConfig{
142-
ID: cfg.InstanceID,
143-
Addr: fmt.Sprintf("%s:%d", instanceAddr, instancePort),
144-
Zone: cfg.InstanceZone,
145-
HeartbeatPeriod: cfg.HeartbeatPeriod,
146-
TokensObservePeriod: 0,
147-
NumTokens: RingNumTokens,
144+
ID: cfg.InstanceID,
145+
Addr: fmt.Sprintf("%s:%d", instanceAddr, instancePort),
146+
Zone: cfg.InstanceZone,
147+
HeartbeatPeriod: cfg.HeartbeatPeriod,
148+
TokensObservePeriod: 0,
149+
NumTokens: RingNumTokens,
150+
KeepInstanceInTheRingOnShutdown: cfg.KeepInstanceInTheRingOnShutdown,
148151
}, nil
149152
}

0 commit comments

Comments
 (0)