-
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
util: Refactor Backoff to return the next step rather than sleeping #71088
Conversation
/cc @logicalhan |
@fedebongio: GitHub didn't allow me to request PR reviews from the following users: logicalhan. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. 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/test-infra repository. |
@sttts can you take a peek at this? |
} | ||
b.Steps-- | ||
if b.Jitter > 0 { | ||
b.Duration = Jitter(b.Duration, b.Jitter) |
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 compounds jitter into future iterations rather than compounding duration consistently and jittering each iteration without affecting future steps, which is a change
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 compounded before
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.
Nm, I see what you mean. Not sure it’s better or worse.
if b.Cap > 0 && b.Duration > b.Cap { | ||
b.Duration = b.Cap | ||
b.Steps = 0 | ||
if b.Jitter > 0 { |
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.
shouldn't this be outside the if b.Cap > 0 && b.Duration > b.Cap
block?
@@ -177,6 +177,32 @@ type Backoff struct { | |||
Factor float64 // Duration is multiplied by factor each iteration | |||
Jitter float64 // The amount of jitter applied each iteration | |||
Steps int // Exit with error after this many steps | |||
Cap time.Duration // The maximum amount of time to wait if set |
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.
is Jitter allowed to exceed Cap?
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.
In this, yes. We wouldn’t want to line up again on cap.
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, just document that the cap is +/- jitter
{initial: &Backoff{Duration: time.Second, Steps: 0}, want: []time.Duration{time.Second, time.Second, time.Second}}, | ||
{initial: &Backoff{Duration: time.Second, Steps: 1}, want: []time.Duration{time.Second, time.Second, time.Second}}, | ||
{initial: &Backoff{Duration: time.Second, Factor: 1.0, Steps: 1}, want: []time.Duration{time.Second, time.Second, time.Second}}, | ||
{initial: &Backoff{Duration: time.Second, Factor: 2, Steps: 2}, want: []time.Duration{2 * time.Second, 4 * time.Second, 4 * time.Second}}, |
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 expected the first duration to be 1 second as before this PR
91a1e03
to
a824e30
Compare
Fixes made. It's easier to read now. |
/retest |
a824e30
to
a2a6637
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: smarterclayton 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 |
/retest
…On Sun, Dec 2, 2018 at 1:10 AM Kubernetes Prow Robot < ***@***.***> wrote:
@smarterclayton <https://github.com/smarterclayton>: The following test
*failed*, say /retest to rerun them all:
Test name Commit Details Rerun command
pull-kubernetes-e2e-kops-aws a2a6637
<a2a6637>
link
<https://gubernator.k8s.io/build/kubernetes-jenkins/pr-logs/pull/71088/pull-kubernetes-e2e-kops-aws/115568/> /test
pull-kubernetes-e2e-kops-aws
Full PR test history <https://gubernator.k8s.io/pr/71088>. Your PR
dashboard <https://gubernator.k8s.io/pr/smarterclayton>. Please help us
cut down on flakes by linking to
<https://git.k8s.io/community/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests>
an open issue
<https://github.com/kubernetes/kubernetes/issues?q=is:issue+is:open> when
you hit one in your PR.
Instructions for interacting with me using PR comments are available here
<https://git.k8s.io/community/contributors/guide/pull-requests.md>. If
you have questions or suggestions related to my behavior, please file an
issue against the kubernetes/test-infra
<https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:>
repository. I understand the commands that are listed here
<https://go.k8s.io/bot-commands>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#71088 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p5Ethx3iNrwK7L-8pWQGcvkbJxDBks5u026-gaJpZM4YiGHw>
.
|
Allows consumers to use Backoff as a generator rather than have to call ExponentialBackoff
a2a6637
to
e62d389
Compare
/retest |
/lgtm |
/retest
…On Tue, Dec 4, 2018 at 2:15 AM Kubernetes Prow Robot < ***@***.***> wrote:
@smarterclayton <https://github.com/smarterclayton>: The following test
*failed*, say /retest to rerun them all:
Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-100-performance e62d389
<e62d389>
link
<https://gubernator.k8s.io/build/kubernetes-jenkins/pr-logs/pull/71088/pull-kubernetes-e2e-gce-100-performance/28662/> /test
pull-kubernetes-e2e-gce-100-performance
Full PR test history <https://gubernator.k8s.io/pr/71088>. Your PR
dashboard <https://gubernator.k8s.io/pr/smarterclayton>. Please help us
cut down on flakes by linking to
<https://git.k8s.io/community/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests>
an open issue
<https://github.com/kubernetes/kubernetes/issues?q=is:issue+is:open> when
you hit one in your PR.
Instructions for interacting with me using PR comments are available here
<https://git.k8s.io/community/contributors/guide/pull-requests.md>. If
you have questions or suggestions related to my behavior, please file an
issue against the kubernetes/test-infra
<https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:>
repository. I understand the commands that are listed here
<https://go.k8s.io/bot-commands>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#71088 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p6FzZF8SwiHSOF4UAlfKhM0UZ3Ngks5u1iEYgaJpZM4YiGHw>
.
|
Allows consumers to use Backoff as a generator rather than have to
call ExponentialBackoff. Extracted from #69890 at reviewer request.
Many other consumers want to cap exponential backoff and this now
allows it.
/kind cleanup