workload

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthActionRestart = iota
	HealthActionSignal
)

Variables

This section is empty.

Functions

func CheckNoCycle

func CheckNoCycle(live []Spec, newSpec Spec) error

CheckNoCycle rejects a spec whose dependency chain loops back to itself through live specs. Unknown IDs have no dependencies, so only known specs participate; the existing graph is assumed acyclic because every submit passed this same check.

Types

type FileRef

type FileRef struct {
	Path   string
	Digest string
	Mode   uint32
}

FileRef points at one file's content in the registry: the container path it materializes to, the blob digest holding its bytes, and the file mode (0 means 0600).

func (FileRef) Validate

func (f FileRef) Validate() error

Validate rejects non-absolute, unclean, or escaping paths, malformed digests, and modes above 0777. Submit answers 400 on any of these; the materializer re-checks paths defensively because journal lines can be hand-written.

type HealthAction

type HealthAction int

type HealthProbe

type HealthProbe string

HealthProbe selects how the fast beat checks a workload: an HTTP endpoint, a TCP connect, or a command run inside the container. Empty means HTTP, so specs written before probes existed behave exactly as they always did.

const (
	HealthProbeHTTP HealthProbe = "http"
	HealthProbeTCP  HealthProbe = "tcp"
	HealthProbeExec HealthProbe = "exec"
)

type Instance

type Instance struct {
	State  State
	ID     uuid.UUID
	SpecID uuid.UUID
	NodeID uuid.UUID
	PID    int
}

type QoS

type QoS string

QoS is a workload's compute allocation class. Higher ranks place first and displace lower ones; displacement flows strictly downward, so eviction loops cannot form.

const (
	// QoSBestEffort runs when room allows and gives way to everything.
	QoSBestEffort QoS = "besteffort"
	// QoSBurstable preempts best-effort and yields to guaranteed.
	QoSBurstable QoS = "burstable"
	// QoSGuaranteed places first and is never preempted.
	QoSGuaranteed QoS = "guaranteed"
)

func (QoS) Rank

func (q QoS) Rank() int

Rank orders classes for placement and preemption. Empty and unknown values rank zero: unspecified work stays best-effort, and a misspelled class fails open instead of failing placed.

func (QoS) Valid

func (q QoS) Valid() bool

Valid reports whether the class is empty or one of the three known values. Submit rejects anything else, loudly.

type Resources

type Resources struct {
	CPUShares uint64 // relative weight (default 1024).
	MemoryMB  int64  // max memory, 0 = unlimited.
}

type RestartPolicy

type RestartPolicy string
const (
	RestartNever     RestartPolicy = "never"
	RestartAlways    RestartPolicy = "always"
	RestartOnFailure RestartPolicy = "on_failure"
)

type Spec

type Spec struct {
	Image          string // OCI reference, e.g. "docker.io/nginx:latest".
	Restart        RestartPolicy
	Command        []string // entrypoint override.
	Env            map[string]string
	Resources      Resources
	ID             uuid.UUID
	AssignedNodeID uuid.UUID `json:"AssignedNodeID"` // which node is assigned to run this.
	// AssignmentEpoch counts reassignments of one workload ID. Higher wins
	// in the view so an orphan move always supersedes the stored copy.
	AssignmentEpoch uint64
	Removed         bool
	HostPort        uint16
	ContainerPort   uint16
	// StopTimeoutSeconds specifies the maximum time (in seconds) allowed for graceful
	// process shutdown via SIGTERM before falling back to SIGKILL. Defaults to 60 seconds if <= 0.
	StopTimeoutSeconds int
	HealthAction       HealthAction
	HealthPath         string // HTTP path for health check endpoint (defaults to "/health").
	// HealthProbe selects the check type: http, tcp, or exec. Empty
	// means http.
	HealthProbe HealthProbe
	// HealthCommand is the argv run inside the container for exec
	// probes. Required when HealthProbe is exec, ignored otherwise.
	HealthCommand []string
	// DependsOn lists workload IDs that must be running on the same node
	// before this workload starts. Unknown, removed, or elsewhere-assigned
	// IDs are ignored, never waited on. Empty means no ordering.
	DependsOn []uuid.UUID
	// Files lists content-addressed files materialized into the container
	// filesystem before start. Blobs live in the registry under the
	// concord-files repo; the journal carries only these pointers.
	Files []FileRef
	// QoS ranks the workload for placement order and preemption:
	// best-effort gives way to everything, guaranteed gives way to
	// nothing. Empty means best-effort. This is compute allocation
	// (who gets the node), not message delivery: ROS-style DDS QoS
	// governs packets, this governs placement. See docs/qos.md.
	QoS QoS
}

type State

type State string
const (
	StatePending State = "pending"
	StateRunning State = "running"
	StateStopped State = "stopped"
)

type Unhealthy

type Unhealthy struct {
	WorkloadID uuid.UUID
}

Unhealthy is the payload of a workload.unhealthy event: the signal action's falling edge. It names the workload so the event converges fleet-wide with the subject attached; an empty payload could never say which workload went sick. Keys stay Go-case like every other journal payload (Spec, Instance), not the SDK's snake_case.

Jump to

Keyboard shortcuts

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