health

package
v1.76.13 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LabelKey = "health.deckhouse.io/package"

LabelKey is the workload label whose value identifies the owning package. The same constant is used by the indexer, the event handlers, and any caller that wants to add the label to a workload manifest.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(name string, event Event)

Callback is invoked from the reconcile goroutine whenever a package's reduced health changes. The callback must not block and must not call back into the Service.

type Event

type Event struct {
	Health Health
}

Event is the payload delivered to Callback on every package-health transition. It carries only what the consumer needs: the new State and a short human-readable Message naming the dominant workload (for example "Deployment/api: ProgressDeadlineExceeded"). The package name is the first argument of Callback and is intentionally not duplicated here. Because Callback is invoked only on transitions, State always differs from the value reported in the previous Event for the same package.

type Health

type Health struct {
	State   State
	Message string
}

Health is the reduced workload-health snapshot for one package. State is the machine-readable enum; consumers map it into a K8s condition's reason field (the enum values are already valid reason strings). Message carries the dominant-workload detail ("Kind/Name: cause") and flows into the condition's message field. StateScaled is the all-healthy case and carries no Message.

type Service

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

Service watches per-package workload statuses via an embedded Monitor and reduces them to a single State per package. Transitions are edge-triggered: the configured Callback is invoked only when a package's reduced State differs from the last reported value.

The Service owns the Monitor and its lifecycle. Construction is I/O-free; goroutines and informers start in Start and stop in Stop.

func NewService

func NewService(client kubernetes.Interface, cb Callback, logger *log.Logger) (*Service, error)

NewService constructs a Service. It does not start any goroutines or perform any I/O; that happens in Start. The callback is invoked on every package health transition and must be non-nil and non-blocking.

func (*Service) Start

func (s *Service) Start()

Start launches the background reconcile goroutine and returns immediately. Safe to call more than once; only the first call has any effect. Pair every Start with a Stop to release informer and queue resources.

func (*Service) Stop

func (s *Service) Stop()

Stop waits for the reconcile goroutine to drain (caches stopped, queue shut down, in-flight reconciles finished). Must be called after Start.

type State

type State string
const (
	// StateUnknown means the package has no known workloads.
	StateUnknown State = "Unknown"
	// StateReconciling means at least one workload is rolling out
	// (generation drift, replicas catching up, revision swap) and none
	// have failed. The controller is still doing work; ask again later.
	StateReconciling State = "Reconciling"
	// StateScaled means every workload is at the desired replica count
	// and the controller has nothing left to reconcile.
	StateScaled State = "Scaled"
	// StateDegraded means at least one workload is Failed, or has been
	// observed Terminating while still in cache.
	StateDegraded State = "Degraded"
)

State values returned to callbacks. The zero value of State is the empty string, not StateUnknown — code that switches on State should rely on the named constants below, not on default-value behavior.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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