Skip to content

Commit 1b3d767

Browse files
authored
Merge pull request #7062 from SungJin1212/fix-panic-when-runtime-config-null
fix panic when the runtime config is null
2 parents d0f3b96 + 00a055e commit 1b3d767

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
* [BUGFIX] Store Gateway: Avoid race condition by deduplicating entries in bucket stores user scan. #6863
101101
* [BUGFIX] Runtime-config: Change to check tenant limit validation when loading runtime config only for `all`, `distributor`, `querier`, and `ruler` targets. #6880
102102
* [BUGFIX] Distributor: Fix the `/distributor/all_user_stats` api to work during rolling updates on ingesters. #7026
103+
* [BUGFIX] Runtime-config: Fix panic when the runtime config is `null`. #7062
103104

104105
## 1.19.1 2025-09-20
105106

pkg/cortex/runtime_config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ func (l runtimeConfigLoader) load(r io.Reader) (any, error) {
8585
if strings.Contains(targetStr, target) {
8686
// only check if target is `all`, `distributor`, "querier", and "ruler"
8787
// refer to https://github.com/cortexproject/cortex/issues/6741#issuecomment-3067244929
88-
for _, ul := range overrides.TenantLimits {
89-
if err := ul.Validate(l.cfg.Distributor.ShardByAllLabels, l.cfg.Ingester.ActiveSeriesMetricsEnabled); err != nil {
90-
return nil, err
88+
if overrides != nil {
89+
for _, ul := range overrides.TenantLimits {
90+
if err := ul.Validate(l.cfg.Distributor.ShardByAllLabels, l.cfg.Ingester.ActiveSeriesMetricsEnabled); err != nil {
91+
return nil, err
92+
}
9193
}
9294
}
9395
}

pkg/cortex/runtime_config_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ import (
1212
"github.com/cortexproject/cortex/pkg/util/validation"
1313
)
1414

15+
func TestLoadRuntimeConfig_ShouldNoPanicWhenNull(t *testing.T) {
16+
yamlFile := strings.NewReader(`
17+
null
18+
`)
19+
20+
loader := runtimeConfigLoader{cfg: Config{Target: []string{All}}}
21+
_, err := loader.load(yamlFile)
22+
require.NoError(t, err)
23+
}
24+
1525
// Given limits are usually loaded via a config file, and that
1626
// a configmap is limited to 1MB, we need to minimise the limits file.
1727
// One way to do it is via YAML anchors.

0 commit comments

Comments
 (0)