-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 limits package #16489
base: main
Are you sure you want to change the base?
feat: add limits package #16489
Conversation
5d08a8c
to
56df031
Compare
This commit adds a new limits package for enforcing per-tenant limits.
56df031
to
bd84903
Compare
|
||
// EncodeStreamMetadata encodes the stream metadata into a Kafka record | ||
// using the tenantID as the key and partition as the target partition | ||
func EncodeStreamMetadata(partition int32, topic string, tenantID string, streamHash uint64) *kgo.Record { |
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.
@periklis why don't we change it to (*kgo.Record, error)
? Then we can return an error on line 215
?
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.
Agree on that too, we should now hide the error
// DecodeStreamMetadata decodes a Kafka record into a StreamMetadata. | ||
// It returns the decoded metadata and any error encountered. | ||
func DecodeStreamMetadata(record *kgo.Record) (*logproto.StreamMetadata, error) { | ||
if record == nil { |
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.
@periklis Do we need these two checks? It should be expected that the caller passes a non-nil record
that also has a non-nil record.Value
?
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.
Agree with that we can drop them now.
|
||
var ( | ||
tenantPartitionDesc = prometheus.NewDesc( | ||
constants.Loki+"_ingest_limits_partitions", |
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 believe this is no longer recommended, almost all of our new code adds loki
as a string literal.
metadata map[string]map[int32][]streamMetadata // tenant -> partitionID -> streamMetadata | ||
|
||
// Track partition assignments | ||
mtxAssingedPartitions sync.RWMutex |
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.
Need to remove this, we will just use mtx
.
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 believe you have already removed that right?
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.
Yeah but it regressed somehow, need to remove it again.
What this PR does / why we need it:
This commit adds a new limits package for enforcing per-tenant limits. It is the first of a number of pull requests to move code from
feat/usage-tracker
intomain
.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