Skip to content

Commit

Permalink
clean-up from PR review
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
  • Loading branch information
trevorwhitney and DylanGuedes committed Nov 3, 2021
1 parent b59bb0d commit 82fe79e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions pkg/loki/config_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,18 @@ func (c *ConfigWrapper) ApplyDynamicConfig() cfg.Source {
// When using the ingester or common ring config, the loopback interface will be appended to the end of
// the list of default interface names
func applyDynamicRingConfigs(r, defaults *ConfigWrapper) {
if reflect.DeepEqual(r.Common.Ring, defaults.Common.Ring) {
// common ring not set, so use memberlist for all rings if set
if len(r.MemberlistKV.JoinMembers) > 0 {
applyMemberlistConfig(r)
} else {
// neither common ring nor memberlist set, use ingester ring configuration for all rings
useIngesterRingConfig(r, defaults)
}
} else {
// common ring is provided, use that for all rings
if !reflect.DeepEqual(r.Common.Ring, defaults.Common.Ring) {
// common ring is provided, use that for all rings
useCommonRingConfig(r, defaults)
return
}

// common ring not set, so use memberlist for all rings if set
if len(r.MemberlistKV.JoinMembers) > 0 {
applyMemberlistConfig(r)
} else {
// neither common ring nor memberlist set, use ingester ring configuration for all rings
useIngesterRingConfig(r, defaults)
}

}
Expand Down Expand Up @@ -297,7 +298,7 @@ func appendLoopbackInterface(cfg, defaults *ConfigWrapper) {

// applyMemberlistConfig will change the default ingester, distributor, ruler, and query scheduler ring configurations to use memberlist.
// 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 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) {
r.Ingester.LifecyclerConfig.RingConfig.KVStore.Store = memberlistStr
Expand Down
4 changes: 2 additions & 2 deletions pkg/loki/config_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
loki_net "github.com/grafana/loki/pkg/util/net"
)

// Can't use a totally empty yaml file or it causes weird behavior in the unmarhsalling.
// Can't use a totally empty yaml file or it causes weird behavior in the unmarshalling.
const minimalConfig = `---
schema_config:
configs:
Expand Down Expand Up @@ -1093,7 +1093,7 @@ func TestLoopbackAppendingToFrontendV2(t *testing.T) {
assert.NoError(t, err)
assert.NotEmpty(t, defaultIface)

t.Run("when using common or ingester ring configs, loopback should be added interface names", func(t *testing.T) {
t.Run("when using common or ingester ring configs, loopback should be added to interface names", func(t *testing.T) {
config, _, err := configWrapperFromYAML(t, minimalConfig, []string{})
assert.NoError(t, err)
assert.Equal(t, []string{"eth0", "en0", defaultIface}, config.Frontend.FrontendV2.InfNames)
Expand Down

0 comments on commit 82fe79e

Please sign in to comment.