nodehealth

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package nodehealth holds the pure node-liveness decision types shared by the gossip failure detector (internal/daemon/mesh) and the liveness monitor (internal/daemon/api). It is a dependency-free leaf so both can import it without a cycle (the mesh package's tests import api, so api must not import mesh).

Index

Constants

View Source
const GossipDownStaleThreshold = 10 * time.Second

GossipDownStaleThreshold is the flap guard: gossip may only push a node to DOWN once its heartbeat has ALSO been stale at least this long. It is well under the 30s heartbeat deadline, so gossip still accelerates detection, but a transient gossip false-positive alone cannot demote a still-heart-beating node.

Variables

This section is empty.

Functions

This section is empty.

Types

type GossipLiveness

type GossipLiveness struct {
	Alive bool
	// Since is when this alive/dead state was first observed.
	Since time.Time
}

GossipLiveness is the gossip layer's view of one node.

type LivenessInputs

type LivenessInputs struct {
	// GossipKnown is false when gossip has no opinion (single-node, gossip down,
	// or a node it has never seen).
	GossipKnown bool
	GossipAlive bool
	// HeartbeatReceived is whether livestate holds any heartbeat for the node;
	// HeartbeatStaleFor is the age of that heartbeat when it does.
	HeartbeatReceived bool
	HeartbeatStaleFor time.Duration
}

LivenessInputs combines the two detectors for one node.

type Verdict

type Verdict int

Verdict is the durable status the combined signals imply for a node.

const (
	// VerdictNoChange means the signals are inconclusive — leave the status as is.
	VerdictNoChange Verdict = iota
	VerdictAlive
	VerdictDown
)

func Decide

func Decide(in LivenessInputs) Verdict

Decide applies the flap guard (T-56) at the gossip time scale (GossipDownStaleThreshold, ~10s — well under the 30s heartbeat deadline):

  • ALIVE if EITHER signal is fresh — a heartbeat within the threshold, or gossip reporting the node up.
  • DOWN only when gossip reports the node dead AND its heartbeat is stale past the threshold (or never arrived). This is what lets gossip demote a failed node in seconds instead of waiting the full heartbeat deadline.
  • NoChange otherwise — notably when gossip has no opinion and the heartbeat is merely stale: the caller falls back to the heartbeat-only deadline.

Because DOWN needs both detectors to agree, neither can flap a node alone.

Jump to

Keyboard shortcuts

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