Documentation
¶
Overview ¶
Package watchdog provides liveness-oriented heartbeats for background control loops that the liveness probe can't otherwise observe, such as the primary-lease loop in internal/cmd/manager/instance/run/lease.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeaseWatchdog ¶
type LeaseWatchdog struct {
// contains filtered or unexported fields
}
LeaseWatchdog reports whether the primary-lease loop is still attempting lock calls, whether or not they succeed. A stale heartbeat means the loop is wedged, not that renewal fails: a primary that retries against an unreachable API server is handled by the step-down monitor.
func NewLeaseWatchdog ¶
func NewLeaseWatchdog(maxSilence time.Duration) *LeaseWatchdog
NewLeaseWatchdog creates a watchdog that considers the loop stuck once maxSilence has elapsed since the last lock call started or returned, with no call still running.
func (*LeaseWatchdog) Beat ¶
func (w *LeaseWatchdog) Beat()
Beat records lock activity: a call starting or returning.
func (*LeaseWatchdog) IsHealthy ¶
func (w *LeaseWatchdog) IsHealthy() error
IsHealthy reports whether the loop has attempted work recently enough. It always reports healthy until MarkAcquired has been called at least once.
func (*LeaseWatchdog) MarkAcquired ¶
func (w *LeaseWatchdog) MarkAcquired()
MarkAcquired records that the primary lease has been held by this instance at least once. IsHealthy is a no-op until this is called: a replica, or a primary still competing for the lease for the first time, never runs the renewal loop this watchdog is meant to catch a stall in, and must not be fenced for it.
func (*LeaseWatchdog) SetMaxSilence ¶
func (w *LeaseWatchdog) SetMaxSilence(maxSilence time.Duration)
SetMaxSilence changes the silence limit. It only needs to cover the pause between two lock calls: a call still running counts as activity, because how long it may block is the API client's business, not a sign of a wedged loop.
func (*LeaseWatchdog) WrapLock ¶
func (w *LeaseWatchdog) WrapLock(lock resourcelock.Interface) resourcelock.Interface
WrapLock returns a resourcelock.Interface that beats before and after delegating every method call to lock and reports the watchdog healthy while a call is running, so an API server that does not answer is never mistaken for a wedged loop. Get and Update are the only methods actually invoked at runtime by this elector configuration (the cluster controller owns lease creation, so Create is never called), but all methods are wrapped for interface completeness.