Help us shape the future of Go! Take the 2026 Go Developer Survey

comps

package
v1.37.1-stratum.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package comps speaks systemctl-shaped verbs (restart, stop, is-active) to the stratum supervisor's control socket, for the components that are still supervised HOST processes: containerd, kubelet, and the operator.

The control plane is not a host process here: it runs as kubelet-managed static pods, and internal/staticpod owns its lifecycle (manifest re-render to restart, manifest removal to stop).

Index

Constants

This section is empty.

Variables

View Source
var Units = []string{
	"containerd",
	"kubelet",
	"operator",
}

Units is the canonical component roster in start/restart order — the supervisor equivalent of a systemd unit list. Upgrade and uninstall derive their lists from this so adding a component is a one-place change. Not every node runs every entry (workers have no control plane; isolated controllers have no kubelet); callers filter by IsActive.

Functions

func DisableNow

func DisableNow(name string) error

DisableNow stops a component until the next controller restart.

func EnableNow

func EnableNow(name string) error

EnableNow starts a component (enablement is the supervisor's default state, so this is just start — the name survives from the systemd call sites).

func IsActive

func IsActive(name string) bool

IsActive reports whether the component is currently running under the supervisor. No socket (controller not running) means not active, and neither does a component whose socket another process serves.

func IsActiveContext

func IsActiveContext(ctx context.Context, name string) bool

IsActiveContext is IsActive with the supervisor request bounded by ctx.

func Normalize

func Normalize(unit string) string

Normalize maps a legacy unit name (stratum-kubelet) or an alias onto the supervisor's component name (kubelet). Unknown names pass through.

func OperatorCommandLinePattern

func OperatorCommandLinePattern() string

OperatorCommandLinePattern is procid.IsOperator as an extended regular expression over a process's whole command line, for `pkill -f`, which can match nothing else. The executable is any single word, so a release artifact name like stratum-linux-amd64 matches as the supervisor accepts it; what makes it the operator is argv[1] and the Stratum-owned flags, built from the same constants. Those flags are matched in the order cluster.Processes assembles them, where procid.IsOperator accepts any order: TestOperatorPatternAgrees pins the two together, and a cluster test pins the pattern to the real argv.

func ProcessPIDs

func ProcessPIDs(name string) ([]int, error)

ProcessPIDs returns the PIDs of every live Stratum-managed process that ProcessRunning would match for name.

func ProcessRunning

func ProcessRunning(name string) (bool, error)

ProcessRunning reports whether a Stratum-managed host process is still live, even if its supervisor and control socket have died. It deliberately matches the payload paths for containerd and kubelet so a distro-owned process with the same basename does not block uninstall. The operator is recognized only as the stratum binary's explicit subcommand. A probe error means liveness is unknown; callers that would delete the process's state must refuse to act.

func Reload

func Reload(name string, spec supervisor.ProcSpec) error

Reload updates a supervised component's exec definition (path/args/env) in the running supervisor and waits for a new running PID, just like Restart. In-place `stratum upgrade` uses this so a new binary's changed args — e.g. containerd's --config path — take effect immediately instead of the supervisor keeping the old argv until the next full `stratum up`.

func Restart

func Restart(name string) error

Restart bounces a component and waits until it is RUNNING AGAIN — systemctl semantics, which the ported call sites assume. "all" keeps the fire-and-forget behaviour.

func StartAndWaitActive

func StartAndWaitActive(name string, timeout time.Duration) error

StartAndWaitActive starts a component and polls until it is running.

func Status

func Status() (map[string]supervisor.ProcStatus, error)

Status is the supervisor's roster as one snapshot, by component name. An error means the supervisor could not be asked, never that nothing runs: callers deciding what is safe to stop fail closed on it.

func Stop

func Stop(name string) error

Stop takes a component down and keeps it down until Start.

func StopAllIfPresent

func StopAllIfPresent() error

StopAllIfPresent disables every roster entry, including pending starts. Missing/refusing sockets require independent process checks; other errors must not be interpreted as successful shutdown.

func SupervisorRunning

func SupervisorRunning() bool

SupervisorRunning reports whether a stratum supervisor is serving the control socket on this node at all.

func UnitExists

func UnitExists(name string) bool

UnitExists reports whether this node's supervisor manages the component at all (workers have no operator entry).

Types

type RunningSupervisor

type RunningSupervisor struct {
	PID       int
	Exe       string
	Installed bool
}

RunningSupervisor is the process serving the control socket: its pid, the binary it runs as /proc reports it, and whether that is the stratum installed on this node.

func Supervisor

func Supervisor() (RunningSupervisor, error)

Supervisor finds the process serving the control socket from the socket's peer credentials, which every supervisor build has, and compares the binary it runs with version.StratumInstallPath.

func (RunningSupervisor) Stale

func (r RunningSupervisor) Stale() bool

Stale reports a supervisor that is not running the installed stratum: an upgrade replaced the binary under it, so it runs the previous build while the processes it starts run the new one.

Jump to

Keyboard shortcuts

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