Documentation
¶
Overview ¶
Package health answers "is what is running actually working".
It is a separate axis from sync, which answers "does the swarm match git". A stack can be synced and degraded at once, and collapsing the two loses the distinction that makes the view useful — #1 lists per-stack *and* per-service health as one of the things nothing in the Swarm GitOps field does.
Every judgement about a service comes from the chart engine's own exported predicate (charts.ServiceState.Convergence, Eldara-Tech/swarmcli#500). The rules it encodes were each corrected at least once — the running count by actual rather than desired state, the target over active nodes, a completed one-shot job, the stability window measured from task creation, paused as wedged rather than slow — and a second copy would diverge silently in both directions: reporting healthy while a `charts` deploy would still be waiting, or degraded on a stack that is fine.
What this package adds is the part the engine has no opinion on: when a rollout that is merely slow should be called broken, and what a release that is not there at all should read as.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Application ¶
func Application(releases []application.ReleaseStatus) application.Health
Application rolls several releases up to one state for the whole application.
Counts are summed rather than re-derived, so a list row's "7/9" is the same arithmetic the detail view shows per release.
func Release ¶
func Release(in Input) (application.Health, []application.ServiceStatus)
Release rolls one release's services up to a health state, and returns the per-service detail alongside it.
Types ¶
type Input ¶
type Input struct {
// States are the release's live services, from Backend.StackServices.
States []charts.ServiceState
// Installed is false for a release the plan would install: declared in the
// repository, never deployed. That is Missing rather than Degraded — a UI
// has to tell "not there" from "there and broken", and it is also the
// ordinary state of a newly declared release before its first sync.
Installed bool
// SyncFailed reports that the last sync attempted for this application did
// not succeed. It is what turns a rollout that is merely slow into one that
// is broken; see Release.
SyncFailed bool
// ReadFailed reports that the swarm could not be asked, so States is empty
// because nothing answered rather than because nothing is there.
//
// It exists because those two are the same value — a nil slice — coming out
// of charts.Backend.StackServices, which has no error return, and opposite
// findings coming out of Release: one is Missing, the loudest state here,
// and the other is Unknown. Without the distinction a daemon that was
// briefly unreachable flipped every release of an application to Missing and
// paged whoever was listening, for a stack running perfectly (#107).
ReadFailed bool
// AsDeclared names the services a live comparison found running exactly what
// the repository declares.
//
// It exists for one judgement, below: whether a rollback a service is still
// carrying is about anything outstanding. Swarm keeps UpdateStatus on a
// service until its *next* update, so a rollback that restored the spec git
// asks for stays there indefinitely — and no next update is coming, because
// there is no drift, so nothing redeploys it, so nothing clears it. The
// release read Degraded for ever over an event that had already put the
// service back where it belongs (#130).
//
// Empty is the ordinary value and asserts nothing. Drift detection is a
// per-application setting, so most callers made no comparison at all, and a
// status with no evidence against it is taken at face value.
AsDeclared []string
}
Input is what one release's health is decided from.