readiness

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

ABOUTME: Cache-sync readiness gate for controller-runtime managers. Reports not-ready on ABOUTME: /readyz until the informer cache has synced, so kubelet traffic waits for warm state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

Gate is a readiness probe that flips to ready once WaitFunc returns true. It implements manager.Runnable so the manager drives the wait in its own goroutine, and its Check method satisfies healthz.Checker for registration with manager.AddReadyzCheck.

The gate opts out of leader election: every replica must answer /readyz truthfully, not just the leader, because caches sync on all replicas and hot standbys are reachable via Service endpoints.

func NewGate

func NewGate(wait WaitFunc) *Gate

NewGate returns a Gate that becomes ready the first time wait returns true. Typical call site: readiness.NewGate(mgr.GetCache().WaitForCacheSync).

func (*Gate) Check

func (g *Gate) Check(_ *http.Request) error

Check is a healthz.Checker that reports not-ready until the cache is synced.

func (*Gate) NeedLeaderElection

func (g *Gate) NeedLeaderElection() bool

NeedLeaderElection returns false so the gate runs on every replica.

func (*Gate) Start

func (g *Gate) Start(ctx context.Context) error

Start blocks until WaitFunc returns, then records the outcome. It is safe to return nil on a failed sync: Check stays not-ready, the manager is already tearing down if ctx was cancelled, and propagating an error here would crash the process without adding signal.

type WaitFunc

type WaitFunc func(ctx context.Context) bool

WaitFunc matches cache.Cache.WaitForCacheSync: block until the caches are synced or ctx is cancelled, returning whether the sync succeeded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL