Documentation
¶
Overview ¶
Package nodehealth implements the node health check: the reconcile.Controller that converges a node's observed heartbeat (internal/store's last_seen_at, kept fresh by internal/agent.Server's periodic touch loop while a node's gRPC session stays open) against its recorded Status, the same architectural pattern internal/reconcile/application and internal/reconcile/database already establish (level-triggered, a narrow store interface for testability, one controller instance per resource), applied to a node instead of a service or database.
This exists specifically because internal/agent.Server.Session already flips a node's Status to Offline synchronously when its gRPC stream ends (a graceful disconnect), but a stream that never ends cleanly (a hard process kill, a severed network link with no TCP FIN) leaves Status stuck at Online forever with nothing to notice otherwise. This controller is that "otherwise": every reconcile pass re-reads LastSeenAt fresh from the store (never cached) and compares it against a timeout, the same level-triggered principle required of every controller in this codebase, so a hung connection is discovered on the very next resync tick rather than staying silently wrong until someone happens to look.
Index ¶
Constants ¶
const ConditionType = "Heartbeat"
ConditionType is the Type of the single condition this controller reports. Exported so internal/api's handleGetNodeHealth (and any future caller reading internal/store.GetConditions results) can name it without duplicating the string.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller converges one named node's observed heartbeat (read fresh from Store on every Reconcile, never cached) against its Status.
type Option ¶
type Option func(*Controller)
Option configures optional Controller behavior.
func WithClock ¶
WithClock overrides the controller's notion of "now", for deterministic tests. Without one configured, time.Now is used.
func WithPendingExpiry ¶
WithPendingExpiry frees the name and placement of a node that never connected within d.
type Store ¶
type Store interface {
GetNode(ctx context.Context, id string) (*store.Node, error)
UpdateNodeStatus(ctx context.Context, id string, status store.NodeStatus) error
}
Store is the narrow surface this controller needs from internal/store, so tests can fake it without a real database. *store.DB satisfies this structurally.