Skip to content

Commit 3fb0d4d

Browse files
56quarterspracucci
andauthored
Ensure missing runtime ingester settings are nil (#4246)
* Ensure missing runtime ingester settings are nil Make sure that omitted or missing ingester configuration that is part of runtime configuration is treated as `nil` instead of an empty object. This fixes an issue where the settings in the empty object were overriding global default ingester limits. Fixes #4228 Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com> * Update CHANGELOG.md Signed-off-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Marco Pracucci <marco@pracucci.com>
1 parent 84d510e commit 3fb0d4d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* [BUGFIX] Ruler: fix `/ruler/rule_groups` endpoint doesn't work when used with object store. #4182
4444
* [BUGFIX] Ruler: Honor the evaluation delay for the `ALERTS` and `ALERTS_FOR_STATE` series. #4227
4545
* [BUGFIX] Fixed cache fetch error on Redis Cluster. #4056
46+
* [BUGFIX] Ingester: fix issue where runtime limits erroneously override default limits. #4246
4647

4748
## Blocksconvert
4849

pkg/cortex/runtime_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type runtimeConfigValues struct {
2828

2929
IngesterChunkStreaming *bool `yaml:"ingester_stream_chunks_when_using_blocks"`
3030

31-
IngesterLimits ingester.InstanceLimits `yaml:"ingester_limits"`
31+
IngesterLimits *ingester.InstanceLimits `yaml:"ingester_limits"`
3232
}
3333

3434
// runtimeConfigTenantLimits provides per-tenant limit overrides based on a runtimeconfig.Manager
@@ -134,7 +134,7 @@ func ingesterInstanceLimits(manager *runtimeconfig.Manager) func() *ingester.Ins
134134
return func() *ingester.InstanceLimits {
135135
val := manager.GetConfig()
136136
if cfg, ok := val.(*runtimeConfigValues); ok && cfg != nil {
137-
return &cfg.IngesterLimits
137+
return cfg.IngesterLimits
138138
}
139139
return nil
140140
}

pkg/cortex/runtime_config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ func TestLoadRuntimeConfig_ShouldLoadEmptyFile(t *testing.T) {
6060
assert.Equal(t, &runtimeConfigValues{}, actual)
6161
}
6262

63+
func TestLoadRuntimeConfig_MissingPointerFieldsAreNil(t *testing.T) {
64+
yamlFile := strings.NewReader(`
65+
# This is an empty YAML.
66+
`)
67+
actual, err := loadRuntimeConfig(yamlFile)
68+
require.NoError(t, err)
69+
70+
actualCfg, ok := actual.(*runtimeConfigValues)
71+
require.Truef(t, ok, "expected to be able to cast %+v to runtimeConfigValues", actual)
72+
73+
// Ensure that when settings are omitted, the pointers are nil. See #4228
74+
assert.Nil(t, actualCfg.IngesterLimits)
75+
}
76+
6377
func TestLoadRuntimeConfig_ShouldReturnErrorOnMultipleDocumentsInTheConfig(t *testing.T) {
6478
cases := []string{
6579
`

0 commit comments

Comments
 (0)