diff --git a/CHANGELOG.md b/CHANGELOG.md index e98870dafcd..70cf7b27312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ * [ENHANCEMENT] Added new Traces api V2[#3912](https://github.com/grafana/tempo/pull/3912) (@javiermolinar) * [ENHANCEMENT] Update to the latest dskit [#3915](https://github.com/grafana/tempo/pull/3915) (@andreasgerstmayr) * [ENHANCEMENT] Reduce allocs building queriers sharded requests [#3932](https://github.com/grafana/tempo/pull/3932) (@javiermolinar) +* [ENHANCEMENT] Allow compaction disablement per-tenant [#3965](https://github.com/grafana/tempo/pull/3965) (@zalegrala) * [ENHANCEMENT] Implement polling tenants concurrently [#3647](https://github.com/grafana/tempo/pull/3647) (@zalegrala) * [BUGFIX] Fix panic in certain metrics queries using `rate()` with `by` [#3847](https://github.com/grafana/tempo/pull/3847) (@stoewer) diff --git a/modules/compactor/compactor.go b/modules/compactor/compactor.go index 7faaed2f60a..a762bb1ace8 100644 --- a/modules/compactor/compactor.go +++ b/modules/compactor/compactor.go @@ -254,6 +254,11 @@ func (c *Compactor) BlockRetentionForTenant(tenantID string) time.Duration { return c.overrides.BlockRetention(tenantID) } +// CompactionDisabledForTenant implements CompactorOverrides +func (c *Compactor) CompactionDisabledForTenant(tenantID string) bool { + return c.overrides.CompactionDisabled(tenantID) +} + func (c *Compactor) MaxBytesPerTraceForTenant(tenantID string) int { return c.overrides.MaxBytesPerTrace(tenantID) } diff --git a/modules/overrides/config.go b/modules/overrides/config.go index 6277fee0eea..88c9cbe615a 100644 --- a/modules/overrides/config.go +++ b/modules/overrides/config.go @@ -164,8 +164,9 @@ type ReadOverrides struct { type CompactionOverrides struct { // Compactor enforced overrides. - BlockRetention model.Duration `yaml:"block_retention,omitempty" json:"block_retention,omitempty"` - CompactionWindow model.Duration `yaml:"compaction_window,omitempty" json:"compaction_window,omitempty"` + BlockRetention model.Duration `yaml:"block_retention,omitempty" json:"block_retention,omitempty"` + CompactionWindow model.Duration `yaml:"compaction_window,omitempty" json:"compaction_window,omitempty"` + CompactionDisabled bool `yaml:"compaction_disabled,omitempty" json:"compaction_disabled,omitempty"` } type GlobalOverrides struct { diff --git a/modules/overrides/config_legacy.go b/modules/overrides/config_legacy.go index 9342dc819c9..65d0190cdef 100644 --- a/modules/overrides/config_legacy.go +++ b/modules/overrides/config_legacy.go @@ -117,8 +117,9 @@ type LegacyOverrides struct { MetricsGeneratorIngestionSlack time.Duration `yaml:"metrics_generator_ingestion_time_range_slack" json:"metrics_generator_ingestion_time_range_slack"` // Compactor enforced limits. - BlockRetention model.Duration `yaml:"block_retention" json:"block_retention"` - CompactionWindow model.Duration `yaml:"compaction_window" json:"compaction_window"` + BlockRetention model.Duration `yaml:"block_retention" json:"block_retention"` + CompactionDisabled bool `yaml:"compaction_disabled" json:"compaction_disabled"` + CompactionWindow model.Duration `yaml:"compaction_window" json:"compaction_window"` // Querier and Ingester enforced limits. MaxBytesPerTagValuesQuery int `yaml:"max_bytes_per_tag_values_query" json:"max_bytes_per_tag_values_query"` @@ -155,8 +156,9 @@ func (l *LegacyOverrides) toNewLimits() Overrides { UnsafeQueryHints: l.UnsafeQueryHints, }, Compaction: CompactionOverrides{ - BlockRetention: l.BlockRetention, - CompactionWindow: l.CompactionWindow, + BlockRetention: l.BlockRetention, + CompactionDisabled: l.CompactionDisabled, + CompactionWindow: l.CompactionWindow, }, MetricsGenerator: MetricsGeneratorOverrides{ RingSize: l.MetricsGeneratorRingSize, diff --git a/modules/overrides/interface.go b/modules/overrides/interface.go index dcca815adaa..9a07352a815 100644 --- a/modules/overrides/interface.go +++ b/modules/overrides/interface.go @@ -71,6 +71,7 @@ type Interface interface { MetricsGeneratorProcessorServiceGraphsEnableVirtualNodeLabel(userID string) bool MetricsGeneratorProcessorSpanMetricsTargetInfoExcludedDimensions(userID string) []string BlockRetention(userID string) time.Duration + CompactionDisabled(userID string) bool MaxSearchDuration(userID string) time.Duration MaxMetricsDuration(userID string) time.Duration DedicatedColumns(userID string) backend.DedicatedColumns diff --git a/modules/overrides/runtime_config_overrides.go b/modules/overrides/runtime_config_overrides.go index bcde85f7f71..daa979d091b 100644 --- a/modules/overrides/runtime_config_overrides.go +++ b/modules/overrides/runtime_config_overrides.go @@ -515,6 +515,11 @@ func (o *runtimeConfigOverridesManager) BlockRetention(userID string) time.Durat return time.Duration(o.getOverridesForUser(userID).Compaction.BlockRetention) } +// CompactionDisabled will not compact tenants which have this enabled. +func (o *runtimeConfigOverridesManager) CompactionDisabled(userID string) bool { + return o.getOverridesForUser(userID).Compaction.CompactionDisabled +} + func (o *runtimeConfigOverridesManager) DedicatedColumns(userID string) backend.DedicatedColumns { return o.getOverridesForUser(userID).Storage.DedicatedColumns } diff --git a/tempodb/compactor.go b/tempodb/compactor.go index e9aa78132b0..7d9e71d5518 100644 --- a/tempodb/compactor.go +++ b/tempodb/compactor.go @@ -104,6 +104,12 @@ func (rw *readerWriter) doCompaction(ctx context.Context) { // Select the next tenant to run compaction for tenantID := tenants[rw.compactorTenantOffset] + + // Skip compaction for tenants which have it disabled. + if rw.compactorOverrides.CompactionDisabledForTenant(tenantID) { + return + } + // Get the meta file of all non-compacted blocks for the given tenant blocklist := rw.blocklist.Metas(tenantID) diff --git a/tempodb/compactor_test.go b/tempodb/compactor_test.go index cdec95d34c1..83f00225626 100644 --- a/tempodb/compactor_test.go +++ b/tempodb/compactor_test.go @@ -48,6 +48,7 @@ func (m *mockJobSharder) Owns(string) bool { return true } type mockOverrides struct { blockRetention time.Duration + disabled bool maxBytesPerTrace int maxCompactionWindow time.Duration } @@ -56,6 +57,10 @@ func (m *mockOverrides) BlockRetentionForTenant(_ string) time.Duration { return m.blockRetention } +func (m *mockOverrides) CompactionDisabledForTenant(_ string) bool { + return m.disabled +} + func (m *mockOverrides) MaxBytesPerTraceForTenant(_ string) int { return m.maxBytesPerTrace } diff --git a/tempodb/tempodb.go b/tempodb/tempodb.go index f2095bd2009..c270a41c080 100644 --- a/tempodb/tempodb.go +++ b/tempodb/tempodb.go @@ -108,6 +108,7 @@ type CompactorSharder interface { type CompactorOverrides interface { BlockRetentionForTenant(tenantID string) time.Duration + CompactionDisabledForTenant(tenantID string) bool MaxBytesPerTraceForTenant(tenantID string) int MaxCompactionRangeForTenant(tenantID string) time.Duration }