-
Notifications
You must be signed in to change notification settings - Fork 692
change: disable legacy overrides by default, add flag to opt in #6741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
electron0zero
merged 7 commits into
grafana:main
from
electron0zero:disable_lagacy_overrides
Mar 25, 2026
+185
−19
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8518f4
feat: disable legacy overrides by default, add flag to opt back in
electron0zero 50d4d4d
chore: migrate jsonnet overrides from legacy to new scoped format
electron0zero e95d4ca
Add CHANGELOG.md
electron0zero bee836e
fix: warn and reject legacy overrides in per-tenant configs
electron0zero ca84196
review comment fixes
electron0zero 63453ba
make generate-manifest
electron0zero 765246e
review comment fixes: reset legacy flag in migration, throttle deprec…
electron0zero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package overrides | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/grafana/dskit/services" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/stretchr/testify/require" | ||
| "go.yaml.in/yaml/v2" | ||
|
electron0zero marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| func TestLegacyOverridesDisabledByDefault(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| configType ConfigType | ||
| enableLegacyOverrides bool | ||
| expectErr string | ||
| }{ | ||
| { | ||
| name: "rejects legacy when EnableLegacyOverrides is false", | ||
| configType: ConfigTypeLegacy, | ||
| expectErr: "DEPRECATED: legacy overrides config format detected but legacy overrides are disabled by default", | ||
| }, | ||
| { | ||
| name: "accepts legacy when EnableLegacyOverrides is true", | ||
| configType: ConfigTypeLegacy, | ||
| enableLegacyOverrides: true, | ||
| }, | ||
| { | ||
| name: "accepts new config regardless of EnableLegacyOverrides", | ||
| configType: ConfigTypeNew, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| cfg := Config{ | ||
| ConfigType: tc.configType, | ||
| EnableLegacyOverrides: tc.enableLegacyOverrides, | ||
| } | ||
|
|
||
| o, err := NewOverrides(cfg, nil, prometheus.NewRegistry()) | ||
| if tc.expectErr != "" { | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), tc.expectErr) | ||
| return | ||
| } | ||
|
|
||
| require.NoError(t, err) | ||
| require.NoError(t, services.StartAndAwaitRunning(context.TODO(), o)) | ||
| require.NoError(t, services.StopAndAwaitTerminated(context.TODO(), o)) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestPerTenantLegacyOverridesDisabledByDefault(t *testing.T) { | ||
| legacyOverrides := &perTenantLegacyOverrides{ | ||
| TenantLimits: map[string]*LegacyOverrides{ | ||
| "tenant1": {MaxBytesPerTrace: 1000}, | ||
| }, | ||
| } | ||
| buff, err := yaml.Marshal(legacyOverrides) | ||
| require.NoError(t, err) | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| enableLegacy bool | ||
| expectErr string | ||
| }{ | ||
| { | ||
| name: "rejects legacy per-tenant overrides when enableLegacy is false", | ||
| expectErr: "DEPRECATED: legacy overrides config format is in use. per-tenant overrides file uses the legacy format but legacy overrides are disabled by default", | ||
| }, | ||
| { | ||
| name: "accepts legacy per-tenant overrides when enableLegacy is true", | ||
| enableLegacy: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| loader := loadPerTenantOverrides(&mockValidator{}, ConfigTypeNew, false, tc.enableLegacy) | ||
| result, err := loader(bytes.NewReader(buff)) | ||
| if tc.expectErr != "" { | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), tc.expectErr) | ||
| } else { | ||
| require.NoError(t, err) | ||
| require.NotNil(t, result) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.