Skip to content
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

Safe per tenant overrides loading #4421

Merged
merged 2 commits into from
Oct 7, 2021

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Oct 6, 2021

Historically, the Limits used to use pass-by-value semantics to clone themselves during per tenant overrides loading. This worked well when the Limits struct had no reference fields (pointers, slices, maps). Adding them, notably ruler_remote_write_headers, ruler_remote_write_relabel_configs, and retention_stream introduced some mutability bugs. Notably, this allowed loading per tenant overrides to mutate the global defaults, which would then be used in subsequent tenant overrides creation. This PR fixes this loophole by introducing a marshaling cycle as a cloning hack.

@owen-d owen-d requested a review from a team as a code owner October 6, 2021 20:31
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo a (non-blocking) nit.

pkg/validation/limits.go Show resolved Hide resolved
@dannykopping
Copy link
Contributor

Merging for now since I'm in the same space and want to avoid a conflict headache. Will make the suggested change if you agree.

@dannykopping dannykopping merged commit 415d4b0 into grafana:main Oct 7, 2021
dannykopping pushed a commit that referenced this pull request Oct 8, 2021
* safe per tenant overrides loading

* exports submap for OverwriteMarshalingStringMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants