Skip to content

Commit d598978

Browse files
authored
feat(distributor): add experimental memberlist kvStore for ha_tracker (#10054)
* feat(distributor): add experimental `memberlist` kvStore for ha_tracker * enable memberlistKV singleton and add ReplicaDesc Codec * docs: add experimental information * docs: address PR comments * add information about non provided cleanup
1 parent d39271a commit d598978

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
* [FEATURE] PromQL: Add experimental `info` function. Experimental functions are disabled by default, but can be enabled setting `-querier.promql-experimental-functions-enabled=true` in the query-frontend and querier. #9879
7373
* [FEATURE] Distributor: Support promotion of OTel resource attributes to labels. #8271
7474
* [FEATURE] Querier: Add experimental `double_exponential_smoothing` PromQL function. Experimental functions are disabled by default, but can be enabled by setting `-querier.promql-experimental-functions-enabled=true` in the query-frontend and querier. #9844
75+
* [FEATURE] Distributor: Add experimental `memberlist` KV store for ha_tracker. You can enable it using the `-distributor.ha-tracker.kvstore.store` flag. You can configure Memberlist parameters via the `-memberlist-*` flags. #10054
7576
* [ENHANCEMENT] Query Frontend: Return server-side `bytes_processed` statistics following Server-Timing format. #9645 #9985
7677
* [ENHANCEMENT] mimirtool: Adds bearer token support for mimirtool's analyze ruler/prometheus commands. #9587
7778
* [ENHANCEMENT] Ruler: Support `exclude_alerts` parameter in `<prometheus-http-prefix>/api/v1/rules` endpoint. #9300

docs/sources/mimir/configure/about-versioning.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ The following features are currently experimental:
8888
- `-distributor.otel-created-timestamp-zero-ingestion-enabled`
8989
- Promote a certain set of OTel resource attributes to labels
9090
- `-distributor.promote-otel-resource-attributes`
91+
- Add experimental `memberlist` key-value store for ha_tracker. Note that this feature is `experimental`, as the upper limits of propagation times have not yet been validated. Additionally, cleanup operations have not yet been implemented for the memberlist entries.
92+
- `-distributor.ha-tracker.kvstore.store`
9193
- Hash ring
9294
- Disabling ring heartbeat timeouts
9395
- `-distributor.ring.heartbeat-timeout=0`

docs/sources/mimir/configure/configuration-parameters/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,8 @@ ha_tracker:
798798
# CLI flag: -distributor.ha-tracker.failover-timeout
799799
[ha_tracker_failover_timeout: <duration> | default = 30s]
800800
801-
# Backend storage to use for the ring. Please be aware that memberlist is not
802-
# supported by the HA tracker since gossip propagation is too slow for HA
803-
# purposes.
801+
# Backend storage to use for the ring. Note that memberlist support is
802+
# experimental.
804803
kvstore:
805804
# Backend storage to use for the ring. Supported values are: consul, etcd,
806805
# inmemory, memberlist, multi.

pkg/distributor/ha_tracker.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
var (
3535
errNegativeUpdateTimeoutJitterMax = errors.New("HA tracker max update timeout jitter shouldn't be negative")
3636
errInvalidFailoverTimeout = "HA Tracker failover timeout (%v) must be at least 1s greater than update timeout - max jitter (%v)"
37-
errMemberlistUnsupported = errors.New("memberlist is not supported by the HA tracker since gossip propagation is too slow for HA purposes")
3837
)
3938

4039
type haTrackerLimits interface {
@@ -152,7 +151,7 @@ type HATrackerConfig struct {
152151
// more than this duration
153152
FailoverTimeout time.Duration `yaml:"ha_tracker_failover_timeout" category:"advanced"`
154153

155-
KVStore kv.Config `yaml:"kvstore" doc:"description=Backend storage to use for the ring. Please be aware that memberlist is not supported by the HA tracker since gossip propagation is too slow for HA purposes."`
154+
KVStore kv.Config `yaml:"kvstore" doc:"description=Backend storage to use for the ring. Note that memberlist support is experimental."`
156155
}
157156

158157
// RegisterFlags adds the flags required to config this to the given FlagSet.
@@ -180,10 +179,6 @@ func (cfg *HATrackerConfig) Validate() error {
180179
return fmt.Errorf(errInvalidFailoverTimeout, cfg.FailoverTimeout, minFailureTimeout)
181180
}
182181

183-
if cfg.KVStore.Store == "memberlist" {
184-
return errMemberlistUnsupported
185-
}
186-
187182
return nil
188183
}
189184

pkg/distributor/ha_tracker_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,15 @@ func TestHATrackerConfig_Validate(t *testing.T) {
430430
}(),
431431
expectedErr: nil,
432432
},
433-
"should fail if KV backend is set to memberlist": {
433+
"should pass if KV backend is set to memberlist": {
434434
cfg: func() HATrackerConfig {
435435
cfg := HATrackerConfig{}
436436
flagext.DefaultValues(&cfg)
437437
cfg.KVStore.Store = "memberlist"
438438

439439
return cfg
440440
}(),
441-
expectedErr: errMemberlistUnsupported,
441+
expectedErr: nil,
442442
},
443443
}
444444

pkg/mimir/modules.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ func (t *Mimir) initMemberlistKV() (services.Service, error) {
10231023
// Append to the list of codecs instead of overwriting the value to allow third parties to inject their own codecs.
10241024
t.Cfg.MemberlistKV.Codecs = append(t.Cfg.MemberlistKV.Codecs, ring.GetCodec())
10251025
t.Cfg.MemberlistKV.Codecs = append(t.Cfg.MemberlistKV.Codecs, ring.GetPartitionRingCodec())
1026+
t.Cfg.MemberlistKV.Codecs = append(t.Cfg.MemberlistKV.Codecs, distributor.GetReplicaDescCodec())
10261027

10271028
dnsProviderReg := prometheus.WrapRegistererWithPrefix(
10281029
"cortex_",
@@ -1037,6 +1038,7 @@ func (t *Mimir) initMemberlistKV() (services.Service, error) {
10371038

10381039
// Update the config.
10391040
t.Cfg.Distributor.DistributorRing.Common.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
1041+
t.Cfg.Distributor.HATrackerConfig.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
10401042
t.Cfg.Ingester.IngesterRing.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
10411043
t.Cfg.Ingester.IngesterPartitionRing.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV
10421044
t.Cfg.StoreGateway.ShardingRing.KVStore.MemberlistKV = t.MemberlistKV.GetMemberlistKV

pkg/mimir/modules_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func TestMultiKVSetup(t *testing.T) {
193193

194194
Distributor: func(t *testing.T, c Config) {
195195
require.NotNil(t, c.Distributor.DistributorRing.Common.KVStore.Multi.ConfigProvider)
196+
require.NotNil(t, c.Distributor.HATrackerConfig.KVStore.MemberlistKV)
196197
require.NotNil(t, c.Ingester.IngesterRing.KVStore.Multi.ConfigProvider)
197198
require.NotNil(t, c.Ingester.IngesterPartitionRing.KVStore.Multi.ConfigProvider)
198199
},

0 commit comments

Comments
 (0)