-
Notifications
You must be signed in to change notification settings - Fork 524
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
query-scheduler: lift tenant data out of userQueue; encapsulate tenant-querier relationship #6133
Conversation
2cfd90d
to
8ded965
Compare
Okay so everything before 5e47b0b is the super basic refactoring just lifting the fields out of |
@francoposa For any work on query-scheduler queue, I kindly ask you to get @charleskorn reviews cause he recently worked on it and has a good understanding of it works. Thanks! |
type userQueue struct { | ||
requests *list.List | ||
} |
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.
this could be flattened so it's no longer a separate type at all
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.
When you say flattened, do you mean making this something like type userQueue *list.List
? If so, that makes sense to me.
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 I may keep it unflattened for now, for when we move to the newer queue implementation.
That way I can wrap both userQueue and the new queue a a basic queue interface so they can be swapped 1:1.
pkg/scheduler/queue/user_queues.go
Outdated
// We set this to nil if number of available queriers <= maxQueriers. | ||
queriers map[string]struct{} | ||
maxQueriers int | ||
tenantQuerierState tenantQuerierState |
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'm not married to embedding tenantQuerierState
into the queues
struct, they could be separated.
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.
Overall direction LGTM.
General comments:
- We seem to use the terms "user" and "tenant" interchangeably throughout this code, and this was true before this PR as well. It would be good to pick one and use it consistently. (This doesn't have to be done in this PR, this could be a separate PR.)
- I'm wondering if we need to rename some types - there are a lot of types with "queue" in their name, which I find confusing. Perhaps we should rename
RequestQueue
toRequestDispatcher
, andqueues
totenantQueueManager
? Then it's clear thattenantQueueManager
is responsible for managing all the different queues for different tenants.
pkg/scheduler/queue/user_queues.go
Outdated
// - it is detected during request enqueueing that a tenant's queriers | ||
// were calculated from an outdated max-queriers-per-tenant value | ||
|
||
queriersByID map[string]*querierConn |
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.
Would be good to clarify which ID we're referring to as the key here.
We have a couple of different IDs stored as strings throughout this file - perhaps adding some specific type definitions would help clarify which one is what and also catch places where we use the wrong kind of ID?
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.
it's a bit verbose because we have to alias search and sort implementations for the slice of querierIDs when we make that a type alias, but I have a good solution - will hold it until your renaming PR gets in because I have to change a bunch of function signatures
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.
Makes sense, thanks.
type userQueue struct { | ||
requests *list.List | ||
} |
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.
When you say flattened, do you mean making this something like type userQueue *list.List
? If so, that makes sense to me.
…enantQuerierState
… on tenantQuerierState
…xt tenant for querier
153a4c9
to
d753be3
Compare
…y tenant ID; push removeTenant down to tenantQuerierAssignments method
… to hide usage of tenantQuerierAssignments from consumers
still WIP on a couple things but stepping away for today
|
everything should be addressed for the moment; save for the further merge conflicts that will need corrected once your renaming PR is in. renamed |
… search for the slice
… search for the slice
… signatures to only take strings rather than QuerierID
@charleskorn I went ahead and made the type alias changes here for I didn't place a huge emphasis on converting every usage of |
Awesome, thanks. I'll pick this up once #6141 is merged.
Leaving that change to a subsequent PR is fine with me. Renaming the file should be fine, but again, doesn't need to be done as part of this PR. |
# Conflicts: # pkg/scheduler/queue/queue.go
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, thanks @francoposa
@francoposa I'll merge this and leave any follow-up refactoring / cleanup (eg. "user" to "tenant") for you when you're back. |
What this PR does
the overall organization of this code is very much open to feedback.
this is supposed to be a pure refactoring PR, not changing behavior
my goals here are to:
userQueue
so we can treat it just like a bare queue, in preparation for replacing it with a queue using the multidimensional-fairness-round-robin approachgetOrAddQueue
(nowgetOrAddTenantQueue
), andgetNextQueueForQuerier
.Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]