From f68cffa06fd6725e1850f08edf6caedcde9a5bf0 Mon Sep 17 00:00:00 2001 From: shantanualshi Date: Thu, 16 Nov 2023 15:33:51 +0530 Subject: [PATCH] Remove deprecated ruler_remote_write_headers --- docs/sources/configure/_index.md | 5 - pkg/ruler/compat.go | 1 - pkg/ruler/registry.go | 5 - pkg/validation/limits.go | 10 -- pkg/validation/limits_test.go | 104 ++++++++++++++++-- .../checker/checker_test.go | 3 - .../deprecated-config.yaml | 1 - .../test-fixtures/config.yaml | 1 - .../test-fixtures/runtime-config.yaml | 1 - 9 files changed, 94 insertions(+), 37 deletions(-) diff --git a/docs/sources/configure/_index.md b/docs/sources/configure/_index.md index 2c52924b127b0..bc58abf80df13 100644 --- a/docs/sources/configure/_index.md +++ b/docs/sources/configure/_index.md @@ -2793,11 +2793,6 @@ The `limits_config` block configures global and per-tenant limits in Loki. # Disable recording rules remote-write. [ruler_remote_write_disabled: ] -# Deprecated: Use 'ruler_remote_write_config' instead. Custom HTTP headers to be -# sent along with each remote write request. Be aware that headers that are set -# by Loki itself can't be overwritten. -[ruler_remote_write_headers: ] - # Configures global and per-tenant limits for remote write clients. A map with # remote client id as key. ruler_remote_write_config: diff --git a/pkg/ruler/compat.go b/pkg/ruler/compat.go index 69dc51c41b8cf..b37613faa03dd 100644 --- a/pkg/ruler/compat.go +++ b/pkg/ruler/compat.go @@ -35,7 +35,6 @@ type RulesLimits interface { ruler.RulesLimits RulerRemoteWriteDisabled(userID string) bool - RulerRemoteWriteHeaders(userID string) map[string]string RulerRemoteWriteConfig(userID string, id string) *config.RemoteWriteConfig RulerRemoteEvaluationTimeout(userID string) time.Duration diff --git a/pkg/ruler/registry.go b/pkg/ruler/registry.go index f46a1991895d2..4d9edd18e9449 100644 --- a/pkg/ruler/registry.go +++ b/pkg/ruler/registry.go @@ -234,11 +234,6 @@ func (r *walRegistry) getTenantRemoteWriteConfig(tenant string, base RemoteWrite // metadata is only used by prometheus scrape configs clt.MetadataConfig = config.MetadataConfig{Send: false} - // overwrite, do not merge - if v := r.overrides.RulerRemoteWriteHeaders(tenant); v != nil { - clt.Headers = v - } - if v := r.overrides.RulerRemoteWriteConfig(tenant, id); v != nil { // overwrite, do not merge if v.Headers != nil { diff --git a/pkg/validation/limits.go b/pkg/validation/limits.go index 708c2f01a5384..f283067ca2780 100644 --- a/pkg/validation/limits.go +++ b/pkg/validation/limits.go @@ -115,15 +115,11 @@ type Limits struct { RulerTenantShardSize int `yaml:"ruler_tenant_shard_size" json:"ruler_tenant_shard_size"` // TODO(dannyk): add HTTP client overrides (basic auth / tls config, etc) - // Ruler remote-write limits. // this field is the inversion of the general remote_write.enabled because the zero value of a boolean is false, // and if it were ruler_remote_write_enabled, it would be impossible to know if the value was explicitly set or default RulerRemoteWriteDisabled bool `yaml:"ruler_remote_write_disabled" json:"ruler_remote_write_disabled" doc:"description=Disable recording rules remote-write."` - // deprecated use RulerRemoteWriteConfig instead - RulerRemoteWriteHeaders OverwriteMarshalingStringMap `yaml:"ruler_remote_write_headers" json:"ruler_remote_write_headers" doc:"deprecated|description=Use 'ruler_remote_write_config' instead. Custom HTTP headers to be sent along with each remote write request. Be aware that headers that are set by Loki itself can't be overwritten."` - RulerRemoteWriteConfig map[string]config.RemoteWriteConfig `yaml:"ruler_remote_write_config,omitempty" json:"ruler_remote_write_config,omitempty" doc:"description=Configures global and per-tenant limits for remote write clients. A map with remote client id as key."` // TODO(dannyk): possible enhancement is to align this with rule group interval @@ -586,12 +582,6 @@ func (o *Overrides) RulerRemoteWriteDisabled(userID string) bool { return o.getOverridesForUser(userID).RulerRemoteWriteDisabled } -// Deprecated: use RulerRemoteWriteConfig instead -// RulerRemoteWriteHeaders returns the headers to use in a remote-write for a given user. -func (o *Overrides) RulerRemoteWriteHeaders(userID string) map[string]string { - return o.getOverridesForUser(userID).RulerRemoteWriteHeaders.Map() -} - // RulerRemoteWriteConfig returns the remote-write configurations to use for a given user and a given remote client. func (o *Overrides) RulerRemoteWriteConfig(userID string, id string) *config.RemoteWriteConfig { if c, ok := o.getOverridesForUser(userID).RulerRemoteWriteConfig[id]; ok { diff --git a/pkg/validation/limits_test.go b/pkg/validation/limits_test.go index 088ce6411a5a9..db481b0c5e948 100644 --- a/pkg/validation/limits_test.go +++ b/pkg/validation/limits_test.go @@ -2,12 +2,15 @@ package validation import ( "encoding/json" + "net/url" "reflect" "testing" "time" "github.com/pkg/errors" + promConfig "github.com/prometheus/common/config" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" @@ -168,10 +171,17 @@ func TestLimitsDoesNotMutate(t *testing.T) { defer func() { defaultLimits = initialDefault }() - + var remoteURL, _ = url.Parse("http://remote-write") // Set new defaults with non-nil values for non-scalar types newDefaults := Limits{ - RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}}, + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + RemoteTimeout: model.Duration(30 * time.Second), + QueueConfig: defaultQueueConfig(), + }, + }, StreamRetention: []StreamRetention{ { Period: model.Duration(24 * time.Hour), @@ -189,11 +199,30 @@ func TestLimitsDoesNotMutate(t *testing.T) { { desc: "map", yaml: ` -ruler_remote_write_headers: - foo: "bar" +ruler_remote_write_config: + tenant: + url: "http://remote-write" + headers: + foo: bar `, exp: Limits{ - RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"foo": "bar"}}, + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + "tenant": { + URL: &promConfig.URL{URL: remoteURL}, + HTTPClientConfig: promConfig.DefaultHTTPClientConfig, + Headers: map[string]string{"foo": "bar"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + }, // Rest from new defaults StreamRetention: []StreamRetention{ @@ -207,10 +236,28 @@ ruler_remote_write_headers: { desc: "empty map overrides defaults", yaml: ` -ruler_remote_write_headers: +ruler_remote_write_config: + tenant: + url: "http://remote-write" + headers: `, exp: Limits{ - + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + "tenant": { + URL: &promConfig.URL{URL: remoteURL}, + HTTPClientConfig: promConfig.DefaultHTTPClientConfig, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + }, // Rest from new defaults StreamRetention: []StreamRetention{ { @@ -236,7 +283,15 @@ retention_stream: }, // Rest from new defaults - RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}}, + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + }, }, }, { @@ -248,7 +303,15 @@ reject_old_samples: true RejectOldSamples: true, // Rest from new defaults - RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}}, + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + }, StreamRetention: []StreamRetention{ { Period: model.Duration(24 * time.Hour), @@ -266,7 +329,15 @@ query_timeout: 5m QueryTimeout: model.Duration(5 * time.Minute), // Rest from new defaults. - RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}}, + RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{ + "default": { + URL: &promConfig.URL{URL: remoteURL}, + Headers: map[string]string{"a": "b"}, + QueueConfig: config.DefaultQueueConfig, + MetadataConfig: config.DefaultMetadataConfig, + RemoteTimeout: model.Duration(30000000000), + }, + }, StreamRetention: []StreamRetention{ { Period: model.Duration(24 * time.Hour), @@ -299,3 +370,16 @@ func TestLimitsValidation(t *testing.T) { require.True(t, errors.Is(limits.Validate(), tc.expected)) } } + +func defaultQueueConfig() config.QueueConfig { + return config.QueueConfig{ + Capacity: 10000, + MaxShards: 50, + MinShards: 1, + MaxSamplesPerSend: 2000, + BatchSendDeadline: model.Duration(5 * time.Second), + MinBackoff: model.Duration(30 * time.Millisecond), + MaxBackoff: model.Duration(5 * time.Second), + RetryOnRateLimit: false, + } +} diff --git a/tools/deprecated-config-checker/checker/checker_test.go b/tools/deprecated-config-checker/checker/checker_test.go index b84b48b89dafe..b49a35f3afaab 100644 --- a/tools/deprecated-config-checker/checker/checker_test.go +++ b/tools/deprecated-config-checker/checker/checker_test.go @@ -48,7 +48,6 @@ var ( "storage_config.aws.dynamodb", "chunk_store_config.write_dedupe_cache_config", "limits_config.unordered_writes", - "limits_config.ruler_remote_write_headers", "limits_config.per_tenant_override_config", "limits_config.per_tenant_override_period", "limits_config.allow_deletes", @@ -79,12 +78,10 @@ var ( expectedRuntimeConfigDeprecates = []string{ "overrides.foo.unordered_writes", - "overrides.foo.ruler_remote_write_headers", "overrides.foo.per_tenant_override_config", "overrides.foo.per_tenant_override_period", "overrides.foo.allow_deletes", "overrides.bar.unordered_writes", - "overrides.bar.ruler_remote_write_headers", "overrides.bar.per_tenant_override_config", "overrides.bar.per_tenant_override_period", "overrides.bar.allow_deletes", diff --git a/tools/deprecated-config-checker/deprecated-config.yaml b/tools/deprecated-config-checker/deprecated-config.yaml index 09e659db9686e..e9426b051af07 100644 --- a/tools/deprecated-config-checker/deprecated-config.yaml +++ b/tools/deprecated-config-checker/deprecated-config.yaml @@ -45,7 +45,6 @@ chunk_store_config: ## NOTE: This will also be used to validate per-tenant overrides. limits_config: unordered_writes: "Will be eventually removed." - ruler_remote_write_headers: "Use ruler_remote_write_config instead." per_tenant_override_config: "Feature renamed to 'runtime configuration', flag deprecated in favor of runtime_config.file" per_tenant_override_period: "Feature renamed to 'runtime configuration', flag deprecated in favor of runtime_config.period" allow_deletes: "Use deletion_mode per tenant configuration instead." diff --git a/tools/deprecated-config-checker/test-fixtures/config.yaml b/tools/deprecated-config-checker/test-fixtures/config.yaml index 502fedc87f0d8..59a76a95f2180 100644 --- a/tools/deprecated-config-checker/test-fixtures/config.yaml +++ b/tools/deprecated-config-checker/test-fixtures/config.yaml @@ -119,7 +119,6 @@ limits_config: unordered_writes: true # DEPRECATED enforce_metric_name: true # DELETED ruler_evaluation_delay_duration: 1m # DELETED - ruler_remote_write_headers: ["foo", "bar"] # DEPRECATED per_tenant_override_config: ./overrides.yaml # DEPRECATED per_tenant_override_period: 5s # DEPRECATED allow_deletes: true # DEPRECATED diff --git a/tools/deprecated-config-checker/test-fixtures/runtime-config.yaml b/tools/deprecated-config-checker/test-fixtures/runtime-config.yaml index eb358459a3128..7aa5d9968b109 100644 --- a/tools/deprecated-config-checker/test-fixtures/runtime-config.yaml +++ b/tools/deprecated-config-checker/test-fixtures/runtime-config.yaml @@ -4,7 +4,6 @@ overrides: unordered_writes: true # DEPRECATED enforce_metric_name: true # DELETED ruler_evaluation_delay_duration: 1m # DELETED - ruler_remote_write_headers: [ "foo", "bar" ] # DEPRECATED per_tenant_override_config: ./overrides.yaml # DEPRECATED per_tenant_override_period: 5s # DEPRECATED allow_deletes: true # DEPRECATED