Skip to content

Commit

Permalink
fix(kube-runtime): setup backoff with builder pattern (#1603)
Browse files Browse the repository at this point in the history
* fix(kube-runtime): setup backoff with builder pattern

Filling the fields manually and leaving the current_interval out
meant that the current_interval is set to its default rather than
track the initial_interval
The builder addresses this for us by setting it on the build method.

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

* test(coverage): add test for default backoff

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

* chore: run just fmt

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

* revert: add test for default backoff

This reverts commit fd3d1c2.

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

---------

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
tiagolobocastro authored Oct 14, 2024
1 parent a6060c4 commit 95cf702
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions kube-runtime/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,13 @@ type Strategy = ResetTimerBackoff<ExponentialBackoff>;
impl Default for DefaultBackoff {
fn default() -> Self {
Self(ResetTimerBackoff::new(
backoff::ExponentialBackoff {
initial_interval: Duration::from_millis(800),
max_interval: Duration::from_secs(30),
randomization_factor: 1.0,
multiplier: 2.0,
max_elapsed_time: None,
..ExponentialBackoff::default()
},
backoff::ExponentialBackoffBuilder::new()
.with_initial_interval(Duration::from_millis(800))
.with_max_interval(Duration::from_secs(30))
.with_randomization_factor(1.0)
.with_multiplier(2.0)
.with_max_elapsed_time(None)
.build(),
Duration::from_secs(120),
))
}
Expand Down

0 comments on commit 95cf702

Please sign in to comment.