Documentation
¶
Overview ¶
Package displaystate is what the display layer's post-admission watcher (internal/displaywatch, ADR 0075) leaves for everyone else: the small state file under the machine-wide state root that carries its heartbeat, its last action and whether it can see llama-swap, and the reader that turns that file into "is a watcher alive".
It is a leaf package (config and gpulease only) because two packages that cannot import each other both need it: internal/displaywatch writes it and imports internal/placement for the guards it re-asks, and internal/placement reads it so the display layer's admission can refuse while nothing is watching a loaded twin. Putting the file's shape and Alive here is what keeps that out of an import cycle.
Index ¶
Constants ¶
const ( // StateFileName is the file under the machine-wide state root that carries the watcher's last // action and heartbeat to offload_status and to the admission guard. StateFileName = "display-watch.json" // HeartbeatEvery bounds how often a check that found nothing to do rewrites the state file: a // reader tells a live watcher from a dead one by it, and a rewrite per 10 s tick would be churn. HeartbeatEvery = 30 * time.Second // CheckBudget bounds one check: the /running read and every unload it issues. CheckBudget = 20 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Alive ¶
Alive says whether a watcher is checking a loaded display twin on this box right now, from the heartbeat it leaves, and the reason in words. It is the question the display layer's admission asks before it lets a twin onto the operator's card: a twin that is admitted with nothing watching it stays there until llama-swap's 300 s idle ttl, however soon the operator is back.
Not alive, each with its own reason: display_watch_sec negative (the operator switched the check off, and a layer that leaves only when something watches it does not open without it); no state path; no heartbeat; a heartbeat older than StaleAfter; a watcher whose /running cannot be read (it is up and blind). Whether the layer guards the desktop at all is the caller's question, not this one's.
The watcher's period is read from cfg as this process knows it. A change to operator_presence or display_watch_sec reaches the watcher only when fleet-serve restarts, which re-reads the config: the watcher does not re-read it between checks.
func StaleAfter ¶
StaleAfter is how old a heartbeat may be before the watcher is called dead: three beats, where a beat is the longer of the check period and the heartbeat throttle, plus the check's own budget.
Types ¶
type Action ¶
type Action struct {
At time.Time `json:"at"`
Layer string `json:"layer"`
// Models are the layer's models that were loaded and failed a guard; Unloaded are the ones that
// came down. Error carries every unload that failed, which leaves its twin where it was.
Models []string `json:"models"`
Unloaded []string `json:"unloaded,omitempty"`
Reasons []string `json:"reasons"`
Error string `json:"error,omitempty"`
}
Action is one thing the watcher did: the twins it set out to unload and why.
type State ¶
type State struct {
CheckedAt time.Time `json:"checked_at"`
IntervalSec int `json:"interval_sec"`
LastAction *Action `json:"last_action,omitempty"`
// ReadErr and BlindSince are set while llama-swap's /running cannot be read: a watcher that cannot
// see what is loaded cannot see a twin to unload, so it is not watching however fresh its
// heartbeat. BlindSince is when the unreadable streak began; both clear on the first good read.
ReadErr string `json:"read_err,omitempty"`
BlindSince *time.Time `json:"blind_since,omitempty"`
}
State is what the watcher leaves for offload_status and the admission guard.