Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

kube-runtime: fix exponential backoff max times #1713

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Changes from all 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
36 changes: 14 additions & 22 deletions kube-runtime/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,39 +885,31 @@

struct ExponentialBackoff {
inner: backon::ExponentialBackoff,
min_delay: Duration,
max_delay: Duration,
factor: f32,
enable_jitter: bool,
builder: backon::ExponentialBuilder,
}

impl ExponentialBackoff {
fn new(min_delay: Duration, max_delay: Duration, factor: f32, enable_jitter: bool) -> Self {
let builder = backon::ExponentialBuilder::default()

Check warning on line 893 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L893

Added line #L893 was not covered by tests
.with_min_delay(min_delay)
.with_max_delay(max_delay)
.with_factor(factor)
.without_max_times();

if enable_jitter {
builder.with_jitter();

Check warning on line 900 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L899-L900

Added lines #L899 - L900 were not covered by tests
}

Self {
inner: backon::ExponentialBuilder::default()
.with_min_delay(min_delay)
.with_max_delay(max_delay)
.with_factor(factor)
.with_jitter()
.build(),
min_delay,
max_delay,
factor,
enable_jitter,
inner: builder.build(),

Check warning on line 904 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L904

Added line #L904 was not covered by tests
builder,
}
}
}

impl Backoff for ExponentialBackoff {
fn reset(&mut self) {
let mut builder = backon::ExponentialBuilder::default()
.with_min_delay(self.min_delay)
.with_max_delay(self.max_delay)
.with_factor(self.factor);
if self.enable_jitter {
builder = builder.with_jitter();
}
self.inner = builder.build();
self.inner = self.builder.build();

Check warning on line 912 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L912

Added line #L912 was not covered by tests
}
}

Expand Down