From f4a68c4c5d9ef22376aaca1cb97abe81b1e88b55 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 7 Oct 2021 13:26:03 -0600 Subject: [PATCH] add comment for memberlist config auto-apply, update changelog Signed-off-by: Trevor Whitney --- CHANGELOG.md | 1 + pkg/loki/config_wrapper.go | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a16dc970b1..20ae757029b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Main +* [4400](https://github.com/grafana/loki/pull/4400) **trevorwhitney**: Config: automatically apply memberlist config too all rings when provided # 2.3.0 (2021/08/06) diff --git a/pkg/loki/config_wrapper.go b/pkg/loki/config_wrapper.go index 455f791de803..d7df5455a475 100644 --- a/pkg/loki/config_wrapper.go +++ b/pkg/loki/config_wrapper.go @@ -71,12 +71,21 @@ func (c *ConfigWrapper) ApplyDynamicConfig() cfg.Source { } } - if len(r.MemberlistKV.JoinMembers) > 0 { - r.Ingester.LifecyclerConfig.RingConfig.KVStore.Store = memberlistStr - r.Distributor.DistributorRing.KVStore.Store = memberlistStr - r.Ruler.Ring.KVStore.Store = memberlistStr - } + applyMemberlistConfig(r) return nil } } + +// applyMemberlistConfig will change the default ingester, distributor, and ruler ring configurations to use memberlist +// if the -memberlist.join_members config is provided. The idea here is that if a user explicitly configured the +// memberlist configuration section, they probably want to be using memberlist for all their ring configurations. +// Since a user can still explicitly override a specific ring configuration (for example, use consul for the distributor), +// it seems harmless to take a guess at better defaults here. +func applyMemberlistConfig(r *ConfigWrapper) { + if len(r.MemberlistKV.JoinMembers) > 0 { + r.Ingester.LifecyclerConfig.RingConfig.KVStore.Store = memberlistStr + r.Distributor.DistributorRing.KVStore.Store = memberlistStr + r.Ruler.Ring.KVStore.Store = memberlistStr + } +}