Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions kube-runtime/src/utils/backoff_reset_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ mod tests {
tokio::time::Instant::now().into_std()
}
}

impl<B: Backoff> ResetTimerBackoff<B> {
pub fn get_backoff(&self) -> &B {
&self.backoff
}
}
}
25 changes: 17 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 All @@ -920,3 +919,13 @@ impl Backoff for DefaultBackoff {
self.0.reset()
}
}

#[cfg(test)]
mod tests {
#[test]
fn backoff_start_interval() {
let default_backoff = super::DefaultBackoff::default().0;
let default_backoff = default_backoff.get_backoff();
assert_eq!(default_backoff.current_interval, default_backoff.initial_interval);
}
}
Comment thread
clux marked this conversation as resolved.
Outdated