-
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
implement ForgetDelayed in delaying queue #113607
implement ForgetDelayed in delaying queue #113607
Conversation
6abfde8
to
58ef226
Compare
@@ -176,7 +180,22 @@ func (q *delayingType) AddAfter(item interface{}, duration time.Duration) { | |||
select { |
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.
reagarding the q.metrics.retry()
in AddAfter
. It depends what we want to measure with it.
We advertize this:
kubernetes/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go
Line 93 in d62cc3d
Help: "Total number of retries handled by workqueue", |
But currently, it only correctly measures calls to AddAfter
. It might not correspond to the number of adds to the workqueue since it also measures retries of the same element that is still waiting (will be queued only once).
This metric might be even less precise when used together with ForgetDelayed
, since it will also count items that were canceled.
We could also decide to trigger the metric just before each q.Add(item)
statement to be sure what we track. Nevertheless it will change the original behaviour.
Thoughts?
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: atiratree The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f1a457f
to
78e7fd2
Compare
78e7fd2
to
ddc35e2
Compare
/cc @liggitt |
Between the API this PR adds and the control of the delaying queue added in #112328, adding the ability to specify what should happen to already-queued, waiting-to-be-queued-earlier and waiting-to-be-queued-later items when you call AddAfter seems more general-purpose and easier/safer to use. Looking at how this capability would be used in #113605, the intent there looks to be "add after and preempt any waiting-to-be-queued items". Doing that with a single AddAfterWithOptions call that indicates exactly what it wants to happen to any existing waiting-to-be-queued items seems better. |
@liggitt thanks for bringing this PR to my attention. It will indeed cover most of our needs and is much more wholesome solution. Closing this PR and starting a discussion in the other one |
What type of PR is this?
/kind feature
What this PR does / why we need it:
#108266 issue is caused by inability of controllers to cancel scheduled insertions to the queue when using
AddAfter
. This PR proposes a new function calledForgetDelayed
that would achieve this.I am trying to showcase how this would be used in the fix #113605 of the mentioned bug.
This was also suggested way back in kubernetes/client-go#131 and it seems it would also help other people.
Which issue(s) this PR fixes:
Fixes kubernetes/client-go#131
Special notes for your reviewer:
Does this PR introduce a user-facing change?
new
ForgetDelayed
method for consumers ofRateLimitingInterface
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: