-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat: Add a new enforced_labels
limit
#15704
Conversation
pkg/distributor/distributor.go
Outdated
@@ -510,6 +510,16 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log | |||
continue | |||
} | |||
|
|||
if missing, lbMissing := d.missingEnforcedLabels(stream, tenantID, validationContext); missing { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do this after
lbs, stream.Labels, stream.Hash, err = d.parseStreamLabels(validationContext, stream.Labels, stream)
So we can reuse the lbs
instead of implementing fetchLbs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. pushed a commit addressing it, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think we should test this in dev before merging. wdyt?
pkg/distributor/distributor_test.go
Outdated
@@ -427,32 +427,59 @@ func Test_IncrementTimestamp(t *testing.T) { | |||
} | |||
|
|||
func Test_MissingEnforcedLabels(t *testing.T) { | |||
limits := &validation.Limits{} | |||
flagext.DefaultValues(limits) | |||
t.Run("missingEnforcedLabels when isolated does what we expect", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what do you mean by isolated
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function missingEnforcedLabels
being invoked in isolation to the rest of the code 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. Maybe there's a better wording for that but not a big deal
💻 Deploy preview deleted. |
What this PR does / why we need it:
Introduce the new experimental
enforced_labels
limit.By default it is empty but when configured, it configures Loki to only accept push requests which streams have all enforced labels.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR