-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Remove presumptions about what decision has been made #105729
Remove presumptions about what decision has been made #105729
Conversation
// It returns the request removed from the list. | ||
type removeFromFIFOFunc func() *request | ||
// The returned bool indicates whether a change was made. | ||
type removeFromFIFOFunc func() bool |
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 wouldn't personally change this - the fact that it returns a request might be quite useful.
And you don't need it to do the changes you want to do - instead of checking if it is true, you just need to check if it is !=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.
Before this PR, a removeFromFIFOFunc returns the *request
in question regardless of whether it was in the fifo.
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.
hmm, i overlooked it - i opened a PR keeping the same signature type removeFromFIFOFunc func() *request
- #105738. let me know if you want it, otherwise i will close it.
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 am folding it into this PR, thanks.
@@ -592,14 +593,16 @@ func (qs *queueSet) removeTimedOutRequestsFromQueueLocked(queue *queue, fsName s | |||
return false | |||
}) | |||
|
|||
for _, req := range rejects { |
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's the point of moving it here and not handling it above on per-request basis?
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.
"walkFunc must not remove the given request from the fifo"
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.
We could have a more efficient code base if we change fifo::Walk
to allow removal of the current *request
and no other fifo mutations; this would exchange the slice that escapes with a stack-allocated variable holding the next *request
to enumerate.
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 force-push to 62eba5f54bc makes this change, and removes the redundant func enumerate_fifo.
|
||
// walkFunc is called for each request in the list in the | ||
// oldest -> newest order. | ||
// ok: if walkFunc returns false then the iteration stops immediately. | ||
// walkFunc must not remove the given request from the fifo. |
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.
BTW, since there are no comments about other fifo mutations, the careful programmer will be unsure whether any are allowed.
38f6f35
to
62eba5f
Compare
62eba5f
to
e290a6a
Compare
The force-push to e290a6ababf makes a removeFromFIFOFunc return the |
/retest |
/triage accepted |
e290a6a
to
0bc77f6
Compare
The force-push to 0bc77f6b709 is a rebase onto |
0bc77f6
to
06b1658
Compare
The force-push to 06b1658a72d adds a missing period in the comment on removeFromFIFOFunc. |
/retest |
staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/fifo_list.go
Show resolved
Hide resolved
metrics.AddRequestsInQueues(req.ctx, qs.qCfg.Name, req.fsName, -1) | ||
req.NoteQueued(false) | ||
if arrivalLimit.After(req.arrivalTime) { | ||
if req.decision.Set(decisionReject) { |
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:
if req.decision.Set(decisionReject) && req.removeFromQueueLocked() != nil {
if request == nil { // This should never happen. But if it does... | ||
return false | ||
dequeued := false | ||
for qs.totRequestsWaiting != 0 && qs.totSeatsInUse < qs.dCfg.ConcurrencyLimit { |
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.
TBH - I much more preferred the previous pattern - i.e.
- this function actually dispatching at most one item
- having additional function doing a for-loop
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.
Alternatively - can just switch this to a single if:
if qs.totRequestWaiting == 0 || qs.totSeatsInUse >= qs.dCfg.ConcurrencyLimit {
return false
}
// The rest of the code comes here and is also not indented.
06b1658
to
e70999b
Compare
The force-push to e70999b addresses the latest review. |
/lgtm /retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MikeSpreitzer, wojtek-t 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 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR updates queueSet to recognize that a request's decision might have already been made asynchronously due to context cancellation/timeout.
Which issue(s) this PR fixes:
Fixes #105338
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig api-machinery
/cc @tkashem
/cc @wojtek-t
@deads2k
@lavalamp