-
Notifications
You must be signed in to change notification settings - Fork 40k
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
workqueue: make queue as configurable #123347
Conversation
Hi @zhouhaibing089. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
fb4bae7
to
c3f0d65
Compare
/ok-to-test |
|
||
type queue []interface{} | ||
|
||
func (q *queue) Touch(item interface{}) {} |
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
LGTM label has been added. Git tree hash: d1937022f322118f691473778cd8dfc907d1a500
|
/lgtm |
/retest |
/assign @aojea |
why not forking the code? |
Forking is always the last resort (but I made it available in https://github.com/zhouhaibing089/workqueue). It would be super nice to be part of client-go while leaving the different implementations in downstream, since the code structure is mostly (99%) the same. Do you see a good reason to not have this in client-go? I assume this is a pretty minimal change, but people may feel differently, I'm open to discuss. |
All good questions.
In fact, yes. For example, in resourcequota controller, there are primary_queue and priority_queue, and there are two workers dealing with each queue respectively. While it might be fine for the same key being processed in two workers in that scenario, it is certainly not a common pattern - a key should be exclusively handled in one worker.
Yeah, client-go is already used as dependencies in many other external projects. (though may not be "only")
I completely agree and thus why I only proposed an interface change without changing the existing implementation (it is still FIFO queue implemented with Now as I said earlier, there are indeed use cases in kubernetes as well. I'm also open to bring this step even further (for e.g, proposing two-lane-queue implementation in kubernetes by default). |
/triage accepted |
c3f0d65
to
a17c21a
Compare
@@ -33,6 +33,46 @@ type Interface interface { | |||
ShuttingDown() bool | |||
} | |||
|
|||
// Queue is the underlying storage for items. | |||
type Queue interface { | |||
// Touch marks an existing item when it is added again. |
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.
what does it means semantically? I assume it will keep the object in the queue, but might change the position in the queue?
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, it basically says the same item while still in the queue is now being added again. For the implementations which can change the priority (or position in your term), this function can be hooked.
The default queue implementation is mostly FIFO and it is not exchangeable unless we implement the whole `workqueue.Interface` which is less desirable as we have to duplicate a lot of code. There was one attempt done in [kubernetes#109349][1] which tried to implement a priority queue. That is really useful and [knative/pkg][2] implemented something called two-lane-queue. While two lane queue is great, but isn't perfect since a full slow queue can still slow down items in fast queue. This change proposes a swappable queue implementation while not adding extra maintenance effort in kubernetes community. We are happy to maintain our own queue implementation (similar to two-lane-queue) in downstream. [1]: kubernetes#109349 [2]: https://github.com/knative/pkg/blob/main/controller/two_lane_queue.go
a17c21a
to
87b4279
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: heqg, sttts, zhouhaibing089 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM label has been added. Git tree hash: fca36852221393a6479c1cf9688bcf0f36b44f8c
|
The default queue implementation is mostly FIFO and it is not exchangeable unless we implement the whole
workqueue.Interface
which is less desirable as we have to duplicate a lot of code. There was one attempt done in kubernetes/kubernetes#109349 which tried to implement a priority queue. That is really useful and knative/pkg implemented something called two-lane-queue. While two lane queue is great, but isn't perfect since a full slow queue can still slow down items in fast queue.This change proposes a swappable queue implementation while not adding extra maintenance effort in kubernetes community. We are happy to maintain our own queue implementation (similar to two-lane-queue) in downstream.
What type of PR is this?
/kind feature