Documentation
¶
Overview ¶
Package nodelifecycle provides the pre-start, post-start and reconcile phases that a node supervising unit runs around the node stack. The Controller interface is keyed by slot, but the only implementation is the container isolation mode's, used by the hidden node-lifecycle command.
It is intentionally separate from pkg/agent/nspawnlifecycle, which is tied to nspawn config regeneration and NVIDIA rewiring and must stay unchanged for rollback stability. The overlap is small (the three phase names and a systemd reload), so it is duplicated rather than shared.
Index ¶
Constants ¶
const ( // DefaultReadyTimeout bounds PostStart's wait for the stack to be running. DefaultReadyTimeout = 2 * time.Minute // DefaultAfterStartTimeout bounds AfterStart on its own, apart from the // readiness wait, so it is not limited to what remained of it. DefaultAfterStartTimeout = 3 * time.Minute // PostStartBudget is the longest PostStart takes with the defaults. PostStartBudget = DefaultReadyTimeout + DefaultAfterStartTimeout )
The default bounds of PostStart. The supervising unit's start timeout is derived from PostStartBudget, so they are one constant, not two numbers that have to be kept equal.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface {
// Regenerate re-renders the backend's host-side configuration for a slot.
Regenerate(ctx context.Context, slot string) error
// Running reports whether the node stack for the slot is up, with a
// human readable detail when it is not.
Running(ctx context.Context, slot string) (running bool, detail string, err error)
// Restart restarts the node stack for the slot (never the host).
Restart(ctx context.Context, slot string) error
}
Controller is what the lifecycle needs from an isolation backend, keyed by slot so this package does not depend on a concrete backend.
type Lifecycle ¶
type Lifecycle struct {
Log *slog.Logger
Controller Controller
// ReloadSystemd reloads systemd units after configuration is regenerated.
ReloadSystemd func(ctx context.Context) error
// AfterStart, when set, runs at the end of PostStart once the stack is
// running, with the slot. The container mode uses it to wire GPUs, which
// needs the stack up. Its failure fails PostStart.
AfterStart func(ctx context.Context, slot string) error
// ReadyTimeout bounds PostStart's wait for the stack to be running. Zero
// is DefaultReadyTimeout.
ReadyTimeout time.Duration
// AfterStartTimeout bounds AfterStart. Zero is DefaultAfterStartTimeout.
AfterStartTimeout time.Duration
// Peer, when set, returns the slot whose node stack must not run at the
// same time as slot's. PreStart refuses while it runs.
Peer func(slot string) string
// PollInterval is the wait between readiness checks.
PollInterval time.Duration
}
Lifecycle implements the three phases.
func (*Lifecycle) PostStart ¶
PostStart waits for the node stack to be running after the supervising unit starts, then runs AfterStart. It fails when the stack is not running within ReadyTimeout or AfterStart fails.