Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring query-frontend interface names with loopback device #4586

Merged
merged 3 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/loki/config_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func applyPathPrefixDefaults(r *ConfigWrapper, defaults ConfigWrapper) {
func appendLoopbackInterface(r *ConfigWrapper) {
if loopbackIface, err := loki_net.LoopbackInterfaceName(); err == nil {
r.Ingester.LifecyclerConfig.InfNames = append(r.Ingester.LifecyclerConfig.InfNames, loopbackIface)
r.Config.Frontend.FrontendV2.InfNames = append(r.Config.Frontend.FrontendV2.InfNames, loopbackIface)
}
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/loki/config_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -993,3 +993,25 @@ query_scheduler:
assert.Equal(t, config.Ingester.LifecyclerConfig.InfNames, []string{"eth0", "en0", defaultIface})
})
}

func TestLoopbackAppendingToFrontendV2(t *testing.T) {
defaultIface, err := loki_net.LoopbackInterfaceName()
assert.NoError(t, err)
assert.NotEmpty(t, defaultIface)

t.Run("by default, loopback should be in FrontendV2 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)
})

t.Run("loopback shouldn't be in FrontendV2 interface names if set by user", func(t *testing.T) {
yamlContent := `frontend:
instance_interface_names:
- otheriface`

config, _, err := configWrapperFromYAML(t, yamlContent, []string{})
assert.NoError(t, err)
assert.Equal(t, []string{"otheriface"}, config.Frontend.FrontendV2.InfNames)
})
}