-
-
Notifications
You must be signed in to change notification settings - Fork 330
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 Backoff
wrapper that implements client-go's reset timer behaviour
#729
Add Backoff
wrapper that implements client-go's reset timer behaviour
#729
Conversation
Signed-off-by: Teo Klestrup Röijezon <[email protected]>
d8ad2fa
to
bb273ce
Compare
assert_eq!(backoff.next_backoff(), Some(Duration::from_secs(2))); | ||
} | ||
|
||
struct TokioClock; |
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.
Need a pausable clock source for tests.
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.
Great tests once again.
|
||
use backoff::{backoff::Backoff, Clock, SystemClock}; | ||
|
||
/// A [`Backoff`] wrapper that resets after a fixed duration has elapsed. |
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.
Think this is great. I was initially going to suggest
/// A [`Backoff`] wrapper that resets after a fixed duration has elapsed
///
/// This is used to reduce load during upstream unhealthiness and is similar to
/// [apimachinery's backoffmanager](https://github.com/kubernetes/apimachinery/blob/7149480564b7d40046f19040efa20171b49059ae/pkg/util/wait/wait.go#L310-L349).
but will leave a comment for that in the place where we instantiate it in Observer
wrapping ExponentialBackoff
.
what you have here is a more generic building block.
assert_eq!(backoff.next_backoff(), Some(Duration::from_secs(2))); | ||
} | ||
|
||
struct TokioClock; |
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.
Great tests once again.
As for where to put this; maybe we should try to upstream this into |
other possibilities could be to:
|
* implement backoff for watcher - for #577 Signed-off-by: clux <[email protected]> * move magic number into strategy Signed-off-by: clux <[email protected]> * expose backoff from watcher and semi-propagate into controller awkward. will write a comment Signed-off-by: clux <[email protected]> * potential abstraction Signed-off-by: clux <[email protected]> * another builder layer; allow eliding ListParams Signed-off-by: clux <[email protected]> * forgot to add file Signed-off-by: clux <[email protected]> * easy parts of code review Signed-off-by: clux <[email protected]> * rewrite as a helper (take N) jesus this stuff is hard. Signed-off-by: clux <[email protected]> * rename as suggested Signed-off-by: clux <[email protected]> * Reimplement watcher backoff as FSM (#720) * Fix clippy warnings Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Reimplement watch backoff as FSM Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Remove useless lifetime bounds Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Silence clippy size warning Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Silence clippy properly this time around Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Split StreamBackoff into a separate utils module Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Backoff tests Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Add stream close test Signed-off-by: Teo Klestrup Röijezon <[email protected]> * remove backoff pin, fix docs Signed-off-by: clux <[email protected]> * newline Signed-off-by: clux <[email protected]> * Add `Backoff` wrapper that implements client-go's reset timer behaviour (#729) Signed-off-by: Teo Klestrup Röijezon <[email protected]> * use new reset backoff and replicate client-go reflector values Signed-off-by: clux <[email protected]> * fix node watcher example Signed-off-by: clux <[email protected]> * Use released `backoff` Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Factor out default `Backoff` Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Add note to `watcher` about backoff Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Added backoff to Controller Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Changelog Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Revert `Observer` for now Signed-off-by: Teo Klestrup Röijezon <[email protected]> * The clippyman comes for us all, eventually And we must all pay our due respects, or pay the price. Signed-off-by: Teo Klestrup Röijezon <[email protected]> * Fix build warnings Signed-off-by: Teo Klestrup Röijezon <[email protected]> * remove backoff_watch Signed-off-by: clux <[email protected]> * doc tweaks Signed-off-by: clux <[email protected]> * sentence Signed-off-by: clux <[email protected]> * upgrading backoff is not actually breaking Signed-off-by: clux <[email protected]> Co-authored-by: Teo Klestrup Röijezon <[email protected]> Co-authored-by: Teo Klestrup Röijezon <[email protected]>
See #703 (comment)
Not sure how we want to expose this. Feels like kube-runtime is starting to pick up on a lot of utility stuff that doesn't have much to do with Kubernetes.