Skip to content

Fix timer drain bug

Mikhail Mazurskiy requested to merge ash2k/timer-drain-bug into master

Found while looking into #386 (closed).

FYI @timofurrer

From https://pkg.go.dev/k8s.io/apimachinery/pkg/util/wait#BackoffManager:

// Backoff returns a shared clock.Timer that is Reset on every invocation. This method is not
// safe for use from multiple threads. It returns a timer for backoff, and caller shall backoff
// until Timer.C() drains. If the second Backoff() is called before the timer from the first
// Backoff() call finishes, the first timer will NOT be drained and result in undetermined
// behavior.

So the solution is to drain the channel. This backoff API is so brittle! https://github.com/kubernetes/kubernetes/pull/101475

Edited by Mikhail Mazurskiy

Merge request reports