-
-
Notifications
You must be signed in to change notification settings - Fork 324
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 handling for watcher and Controller #703
Conversation
This comment has been minimized.
This comment has been minimized.
Sorry about the slow reviewing, I've been (and still am) home sick. I'll try to have a closer look when I'm back alive... |
No rush. Hope you get some rest and get to recover! |
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
awkward. will write a comment Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
5a2bd69
to
ff2cfe4
Compare
jesus this stuff is hard. Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
* Fix clippy warnings Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Reimplement watch backoff as FSM Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Remove useless lifetime bounds Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Silence clippy size warning Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Silence clippy properly this time around Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Split StreamBackoff into a separate utils module Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Backoff tests Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se> * Add stream close test Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: clux <sszynrae@gmail.com>
…ur (#729) Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
And we must all pay our due respects, or pay the price. Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
…eanup Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
Backoff watcher cleanup
Codecov Report
@@ Coverage Diff @@
## master #703 +/- ##
==========================================
+ Coverage 70.83% 71.15% +0.31%
==========================================
Files 52 54 +2
Lines 3405 3529 +124
==========================================
+ Hits 2412 2511 +99
- Misses 993 1018 +25
Continue to review full report at Codecov.
|
impl<S: TryStream, B: Backoff> StreamBackoff<S, B> { | ||
pub fn new(stream: S, backoff: B) -> Self { | ||
Self { | ||
stream, | ||
backoff, | ||
state: State::Awake, | ||
} | ||
} | ||
} |
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.
One thought on StreamBackoff
: because this is effectively a stream analogue of https://docs.rs/backoff/0.4.0/backoff/fn.retry.html , maybe we should allow bailing at bad errors in a simiar way to how backoff.retry defines its error type: https://docs.rs/backoff/0.4.0/backoff/enum.Error.html ?
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.
Hm, maybe. I'd lean towards KISS for now, and letting @ihrwein decide the future plan in the upstreaming PR (ihrwein/backoff#50).
kube-runtime/src/watcher.rs
Outdated
/// Pauses the stream for a while (as defined by `backoff`) after each [`Err`]. | ||
pub fn backoff_watch<K, B>( | ||
stream: impl Stream<Item = Result<Event<K>>> + Send, | ||
backoff: B, | ||
) -> impl Stream<Item = Result<Event<K>>> + Send | ||
where | ||
K: Resource + Send, | ||
B: Backoff + Send, | ||
{ | ||
StreamBackoff::new(stream, backoff) | ||
} |
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 appears unused now after the Observer
cancel. I can remove this?
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.
Good catch. This was an attempt to be somewhat more ergonomic and point people who were already working in the watcher
module towards it (rather than focusing on the implementation details of StreamBackoff
itself). We can either drop this, or revert StreamBackoff::new
to pub(crate)
and fixing the examples to use backoff_watch
instead.
I'm fine with either.
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 removed it for now. Want to focus on the future chain pipeline before teaching people too much new stuff.
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
backoff_watch
helper from teo Reimplement watcher backoff as FSM #720ResetTimerBackoff
helper from teo AddBackoff
wrapper that implements client-go's reset timer behaviour #729ignored for nowObserver
abstraction aroundwatcher
+backoff_watch
+ResetTimerBackoff
default_backoff
following client-go defaultsintroduces a dependency on
backoff
0.4.0 for parts of this.old notes, no longer relevant not hiding errors
initial experiment with watcher + backoff. injecting a backoff into the main `stream::unfold` of `watcher` and sleeping between steps. It works with `configmapgen_controller` (in say the example where the crd has not been installed); it keeps sleeping until a max time hits (figured we'd set this to something like 10-30minutes) after which the stream ends.
Problems:
watcher
bubbles up the error as it stands - so normal watcher users stop at the first error anywayController
ignores error events from watcher so at some point theController
becomes dysfunctionalSolutions:
We could let the timeout grow almost indefinitely (to like an hour or more backoff) so that
Controller
can always deal with it.We could also expose a new
watcher
error type that wraps the original - so that the user can ignore it easily, but not sure, what that interface would look like yet. Maybe this is something a builder can ignore by default in the way it presents the stream - i.e. ignore until the error has been going on for so lonng.Also, should try to get the magic number baked into the backoff struct (it supports returning None). It didn't work with
- yup works.max_interval
, but looks like it should work with https://docs.rs/backoff/0.3.0/backoff/exponential/struct.ExponentialBackoff.htmlmax_elapsed_time
Anyway, will try more later.