-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add WithDeadlineTimer interface to clock #312
base: master
Are you sure you want to change the base?
Conversation
WithDeadlineTimer interface extends Clock to add NewDeadlineTimer. NewDeadlineTimer is similar to NewTimer, but it returns a timer which fires at the given timestamp. It makes unit testing easier with FakeClock.Step when a test subject is making a timer inside goroutine (e.g., workqueue.NewDelayingQueue). With NewTimer, in some race conditions, a timer never fire if FakeClock.Step is called after getting the base time Now() and calling NewTimer(). This is because the duration passed to timer is calculated against the old timestamp, but inside FakeClock.NewTimer, the targetTime is calculated against the time adjusted by Step. With NewDeadlineTimer, targetTime is not adjusted, which works around this issue.
Welcome @tatsuhiro-t! |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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-sigs/prow repository. |
/reopen |
@mauri870: Reopened this PR. In response to this:
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-sigs/prow repository. |
/remove-lifecycle rotten |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mauri870, tatsuhiro-t 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This is a part of effort to fix kubernetes/kubernetes#125581
WithDeadlineTimer interface extends Clock to add NewDeadlineTimer. NewDeadlineTimer is similar to NewTimer, but it returns a timer which fires at the given timestamp. It makes unit testing easier with FakeClock.Step when a test subject is making a timer inside goroutine (e.g., workqueue.NewDelayingQueue). With NewTimer, in some race conditions, a timer never fire if FakeClock.Step is called after getting the base time Now() and calling NewTimer(). This is because the duration passed to timer is calculated against the old timestamp, but inside FakeClock.NewTimer, the targetTime is calculated against the time adjusted by Step. With NewDeadlineTimer, targetTime is not adjusted, which works around this issue.
Because workqueue.DelayingQueueConfig uses clock.WithTicker and changing it breaks API compatibility, I plan to do type assertion like so to use NewDeadlineTimer if available:
Which issue(s) this PR fixes:
kubernetes/kubernetes#125581
Special notes for your reviewer:
Release note: