Skip to content

Commit

Permalink
Do not clear HTTP client config (#4437)
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
  • Loading branch information
Danny Kopping committed Oct 8, 2021
1 parent 482bb01 commit 90bd99d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/ruler/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func (r *walRegistry) getTenantRemoteWriteConfig(tenant string, base RemoteWrite
overrides.Client.Name = fmt.Sprintf("%s-rw", tenant)
overrides.Client.SendExemplars = false
// TODO(dannyk): configure HTTP client overrides
overrides.Client.HTTPClientConfig = promConfig.HTTPClientConfig{}
// metadata is only used by prometheus scrape configs
overrides.Client.MetadataConfig = config.MetadataConfig{Send: false}
overrides.Client.SigV4Config = nil
Expand Down
20 changes: 20 additions & 0 deletions pkg/ruler/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func setupRegistry(t *testing.T, dir string) *walRegistry {
QueueConfig: config.QueueConfig{
Capacity: defaultCapacity,
},
HTTPClientConfig: promConfig.HTTPClientConfig{
BasicAuth: &promConfig.BasicAuth{
Password: "bar",
Username: "foo",
},
},
Headers: map[string]string{
"Base": "value",
},
Expand Down Expand Up @@ -174,6 +180,20 @@ func TestTenantRemoteWriteConfigDisabled(t *testing.T) {
assert.Len(t, tenantCfg.RemoteWrite, 0)
}

func TestTenantRemoteWriteHTTPConfigMaintained(t *testing.T) {
walDir, err := createTempWALDir()
require.NoError(t, err)
reg := setupRegistry(t, walDir)
defer os.RemoveAll(walDir)

tenantCfg, err := reg.getTenantConfig(enabledRWTenant)
require.NoError(t, err)

// HTTP client config is not currently overrideable, all tenants' configs should inherit base
assert.Equal(t, tenantCfg.RemoteWrite[0].HTTPClientConfig.BasicAuth.Username, "foo")
assert.Equal(t, tenantCfg.RemoteWrite[0].HTTPClientConfig.BasicAuth.Password, promConfig.Secret("<secret>"))
}

func TestTenantRemoteWriteHeaderOverride(t *testing.T) {
walDir, err := createTempWALDir()
require.NoError(t, err)
Expand Down

0 comments on commit 90bd99d

Please sign in to comment.