Documentation
¶
Overview ¶
Package slurm is go/dispatch's adapter for Slurm 25.11 and 26.05. A consumer blank-imports it and names "slurm" as its adapter; slurm.New builds a Backend directly. It owns the meaning: the strictly decoded configuration and its schema, classification of Slurm's v0.0.44 JSON, the gated batch script, the command vocabulary with its identity check and deadline wrapper, and preflight. Scripts reach the cluster through the transport packages, locally on a login node or over SSH.
Spec: https://gitlab.com/phpboyscout/go/dispatch-slurm/-/wikis/specs/0001-the-slurm-adapter
Index ¶
- Constants
- Variables
- func RegisterTransport(name string, f TransportFactory) error
- func Schema() []byte
- type Backend
- func (b *Backend) Capabilities(context.Context, *model.JobSpec) (map[model.Capability]model.Support, error)
- func (b *Backend) Ceased(ctx context.Context, ref model.ObjectRef, last model.ExecutionObs) (model.CessationEvidence, error)
- func (b *Backend) Close() error
- func (b *Backend) Declarations() model.Declarations
- func (b *Backend) DispatchBackend() dispatch.Backend
- func (b *Backend) Find(ctx context.Context, job model.JobID) (model.Discovery, error)
- func (b *Backend) FindMany(ctx context.Context, jobs []model.JobID, states ...model.ObjectState) (map[model.JobID]model.Discovery, error)
- func (b *Backend) Hold(ctx context.Context, ref model.ObjectRef, m model.HoldMeta) error
- func (b *Backend) Inspect(ctx context.Context, ref model.ObjectRef) (model.ObjectObs, error)
- func (b *Backend) Open(ctx context.Context, ref model.ObjectRef) error
- func (b *Backend) Output(ctx context.Context, job model.JobID, submission int, s dispatch.Stream, ...) (io.ReadCloser, error)
- func (b *Backend) Progress(ctx context.Context, ref model.ObjectRef) (model.Progress, error)
- func (b *Backend) Release(ctx context.Context, ref model.ObjectRef, m model.HoldMeta) error
- func (b *Backend) Requeue(ctx context.Context, ref model.ObjectRef, m model.CallMeta) error
- func (b *Backend) RestoreRequeueBit(ctx context.Context, ref model.ObjectRef, m model.CallMeta) error
- func (b *Backend) Rules(_ context.Context, _ model.JobSpec, policy model.RecoveryPolicy) ([]model.RuleSupport, error)
- func (b *Backend) Start(ctx context.Context, req model.StartRequest) (model.ObjectRef, error)
- func (b *Backend) Stop(ctx context.Context, ref model.ObjectRef, _ string) error
- func (b *Backend) StopJob(ctx context.Context, job model.JobID, _ string) (model.StopReport, error)
- func (b *Backend) Warnings() []string
- type Cessation
- type Config
- type Defaults
- type Duration
- type Environment
- type Kubernetes
- type Option
- type Output
- type Placement
- type Preflight
- type Resources
- type SSH
- type Timeouts
- type TransportFactory
Constants ¶
const ( TransportLocal = "local" TransportSSH = "ssh" )
The transports a configuration may name (spec 0001 D3).
const ( SourceKubernetes = "kubernetes" SourceSlurmNode = "slurm-node" SourceCommand = "command" )
The cessation sources.
const ( BootTimeKernel = "kernel" BootTimeUnknown = "unknown" )
What a node's BootTime is, as cessation.bootTime declares it: the kernel's boot, or not known to be, as under slurmd -b, where it is slurmd's start.
const ( KubeAccessDirect = "direct" KubeAccessSSH = "ssh" KubeAccessAuto = "auto" )
How the Kubernetes source reaches its API server: directly, through the SSH connection, or directly and then through SSH when the transport is ssh.
const ControlPathNone = ssh.ControlPathNone
ControlPathNone turns ControlMaster off.
const Name = "slurm"
Name is the adapter's registry name, under which init registers its factory.
const NodePodNodeName = "node-name"
NodePodNodeName maps a Slurm node to the pod of the same name, as Soperator names them; no other mapping exists yet.
Variables ¶
var ErrExpired = fmt.Errorf("%w: the call started past its deadline", model.ErrRejected)
ErrExpired is a deadline-carrying call whose deadline had passed on the Slurm host when it was due to start, so it did nothing (spec 0001 D5, D7).
Functions ¶
func RegisterTransport ¶
func RegisterTransport(name string, f TransportFactory) error
RegisterTransport makes a transport available to the transport key under name. A duplicate is model.ErrAlreadyRegistered, never an overwrite.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is the Slurm adapter: a dispatch.Backend that is also a dispatch.Holder, Requeuer, CessationSignal, OutputReader and MultiFinder.
func New ¶
New validates cfg, opens its transport and runs preflight, whose results fix the Backend's declarations and capabilities (spec 0001 D8).
func (*Backend) Capabilities ¶
func (b *Backend) Capabilities(context.Context, *model.JobSpec) (map[model.Capability]model.Support, error)
Capabilities implements dispatch.Backend with spec 0001 D9's table; Hold and AccountingHistory are the probe's.
func (*Backend) Ceased ¶
func (b *Backend) Ceased(ctx context.Context, ref model.ObjectRef, last model.ExecutionObs) (model.CessationEvidence, error)
Ceased implements dispatch.CessationSignal from the sources cessation.sources names, those the Backend can reach: the Kubernetes source, the Slurm node under cessation.bootTime kernel, and the site's command (spec 0002 D6, D7); Detail names a Slurm-node source left out. last is the latest execution the record saw started, so the answer outlives slurmctld's purge of the job; one with no nodes or no start is never ceased. The object has ceased when, for every node, at least one source says so; an error from one source is not evidence, and Ceased errs only when every source errs. One call is bounded by cessation.timeout. It works on a read-only Backend.
func (*Backend) Declarations ¶
func (b *Backend) Declarations() model.Declarations
Declarations implements dispatch.Backend; they are fixed by preflight.
func (*Backend) DispatchBackend ¶
DispatchBackend returns b as dispatch.Open hands it out. On a cluster whose AuthType gives no landing bound, that is b without Holder and Requeuer: it cannot bound when a hold or requeue lands, so it declares a zero CallBound, and go/dispatch spec 0003 allows a zero CallBound only without both.
func (*Backend) FindMany ¶
func (b *Backend) FindMany(ctx context.Context, jobs []model.JobID, states ...model.ObjectState) (map[model.JobID]model.Discovery, error)
FindMany implements dispatch.MultiFinder: one squeue for every job's name, keeping only objects in states when any are named.
func (*Backend) Hold ¶
Hold implements dispatch.Holder: a far-future StartTime encoding the instance against the object's current submit time, behind the host-side deadline wrapper (spec 0001 D5, D7).
func (*Backend) Inspect ¶
Inspect implements dispatch.Backend: squeue first, then sacct when the job is gone from slurmctld and AccountingHistory is Yes (spec 0001 D5).
func (*Backend) Open ¶
Open implements dispatch.Backend: scontrol release, after the identity check and refusing a hold that is not the gate (spec 0001 D5).
func (*Backend) Output ¶
func (b *Backend) Output(ctx context.Context, job model.JobID, submission int, s dispatch.Stream, follow bool) (io.ReadCloser, error)
Output implements dispatch.OutputReader (spec 0001 D12): the manifest Start wrote names each stream's prefix and suffix; the execution files under it are read in restart order, numerically, and with follow set the stream is followed until ctx ends or the reader is closed.
func (*Backend) Progress ¶
Progress implements dispatch.ProgressReader with one squeue and one read of the current execution's beat file (spec 0001 D12).
func (*Backend) Release ¶
Release implements dispatch.Holder: StartTime=now, only when the instance in force, decoded against the current submit time, is the one m names.
func (*Backend) Requeue ¶
Requeue implements dispatch.Requeuer: Requeue=1, scontrol requeue and Requeue=0 in one detached script, each behind the deadline check, the last run whatever the second returned (spec 0001 D5, D7).
func (*Backend) RestoreRequeueBit ¶
func (b *Backend) RestoreRequeueBit(ctx context.Context, ref model.ObjectRef, m model.CallMeta) error
RestoreRequeueBit implements dispatch.Requeuer: one wrapped Requeue=0.
func (*Backend) Rules ¶
func (b *Backend) Rules(_ context.Context, _ model.JobSpec, policy model.RecoveryPolicy) ([]model.RuleSupport, error)
Rules implements dispatch.Backend (spec 0001 D9, 0003 D3).
func (*Backend) Start ¶
Start implements dispatch.Backend: one script creates the output directory, writes the manifest and submits gated; read-back then proves the object is what was asked for (spec 0001 D5, D6).
func (*Backend) Stop ¶
Stop implements dispatch.Backend: scancel by name and id, so a reused id, which carries another name, is left alone; then squeue verifies (spec 0001 D5). There is no --state=PENDING, because Stop cannot tell a retirement from a stop without racing.
func (*Backend) StopJob ¶
StopJob implements dispatch.Backend: scancel every object of the job by name, then verify in rounds until nothing is alive and every cancelled job's nodes are up, re-issuing the scancel each round, up to KillWait + SlurmdTimeout + 60 s (spec 0001 D5, 0003 D6).
type Cessation ¶
type Cessation struct {
Command string `json:"command,omitempty"`
Timeout Duration `json:"timeout,omitzero"`
BootTime string `json:"bootTime,omitempty"`
Sources []string `json:"sources,omitzero"`
// contains filtered or unexported fields
}
Cessation configures dispatch.CessationSignal: which sources answer, and the site command when one does (spec 0002 D6, D7). Decoding always sets it. Sources is nil for the default and empty for none, which leaves Ceased ErrUnsupported. BootTime is BootTimeKernel only where slurmd runs without -b, and the Slurm-node source runs only then.
type Config ¶
type Config struct {
Transport string `json:"transport,omitempty"`
SSH *SSH `json:"ssh,omitempty"`
Defaults Defaults `json:"defaults,omitzero"`
Output Output `json:"output,omitzero"`
Environment Environment `json:"environment,omitzero"`
Singleton bool `json:"singleton,omitempty"`
Cessation *Cessation `json:"cessation,omitempty"`
Kubernetes *Kubernetes `json:"kubernetes,omitempty"`
Preflight Preflight `json:"preflight,omitzero"`
Timeouts Timeouts `json:"timeouts,omitzero"`
}
Config is the adapter's configuration section, AdapterConfig.Settings (spec 0001 D3). The zero value of an optional field means its default.
type Defaults ¶
type Defaults struct {
Partition string `json:"partition,omitempty"`
Account string `json:"account,omitempty"`
QOS string `json:"qos,omitempty"`
Reservation string `json:"reservation,omitempty"`
Constraint string `json:"constraint,omitempty"`
}
Defaults are sbatch placement defaults, which slurm.Placement overrides per job.
type Duration ¶
Duration is a positive time.Duration written as a Go duration string, such as "10s".
func (Duration) MarshalText ¶
MarshalText writes the duration as a Go duration string.
func (*Duration) UnmarshalText ¶
UnmarshalText reads a Go duration string, refusing zero and negative values.
type Environment ¶
type Environment struct {
Pass []string `json:"pass,omitzero"`
}
Environment lists the variables copied into the batch script at Start. Pass is nil for the default and empty to pass nothing.
type Kubernetes ¶
type Kubernetes struct {
Server string `json:"server"`
Access string `json:"access,omitempty"`
TokenFile string `json:"tokenFile"`
CAFile string `json:"caFile"`
Namespace string `json:"namespace"`
ControllerPod string `json:"controllerPod,omitempty"`
ControllerContainer string `json:"controllerContainer,omitempty"`
NodePod string `json:"nodePod,omitempty"`
}
Kubernetes is the Kubernetes evidence source's API server and credential (spec 0002 D5, D8). The token and CA are files on the caller's host, read at every Open; the token is never logged or stored.
type Option ¶
type Option func(*options)
Option configures New.
func ReadOnly ¶
func ReadOnly() Option
ReadOnly opens a Backend whose writing calls return dispatch.ErrReadOnly before any command, and whose preflight submits no probe.
func WithClock ¶
WithClock reads the caller's time from now, which Find's At and horizon, preflight's clock offset and StopJob's bound use.
func WithExecutor ¶
WithExecutor runs scripts through e instead of the configured transport. The Backend owns e from then on, and closes it.
type Output ¶
type Output struct {
Dir string `json:"dir,omitempty"`
}
Output says where each execution's output goes on the cluster.
type Placement ¶
type Placement struct {
Partition string `json:"partition,omitempty"`
Account string `json:"account,omitempty"`
QOS string `json:"qos,omitempty"`
Reservation string `json:"reservation,omitempty"`
Constraint string `json:"constraint,omitempty"`
}
Placement chooses where a job runs; each non-empty field overrides the matching defaults.* setting for that job.
type Preflight ¶
type Preflight struct {
CacheDir string `json:"cacheDir,omitempty"`
MaxAge Duration `json:"maxAge,omitzero"`
}
Preflight configures the preflight cache on the caller's host. CacheDir must be a real directory of mode 0700 owned by the caller, and is created so when missing; a cache found anywhere else, or through a symlink, is not read.
type Resources ¶
type Resources struct {
GPUType string `json:"gpuType,omitempty"`
CPUsPerTask int `json:"cpusPerTask,omitempty"`
MemPerNodeMiB int `json:"memPerNodeMiB,omitempty"`
Exclusive bool `json:"exclusive,omitempty"`
}
Resources asks Slurm for what JobSpec has no field for: a GPU type, CPUs per task, memory per node and exclusive nodes.
type SSH ¶
type SSH struct {
Host string `json:"host"`
User string `json:"user,omitempty"`
Port int `json:"port,omitempty"`
IdentityFile string `json:"identityFile,omitempty"`
ProxyJump string `json:"proxyJump,omitempty"`
KnownHostsFile string `json:"knownHostsFile,omitempty"`
ConfigFile string `json:"configFile,omitempty"`
ConnectTimeout Duration `json:"connectTimeout,omitzero"`
ControlPath string `json:"controlPath,omitempty"`
ControlPersist Duration `json:"controlPersist,omitzero"`
}
SSH is the closed set of ssh options the adapter can express; it is only valid with transport ssh.
type Timeouts ¶
type Timeouts struct {
Command Duration `json:"command,omitzero"`
Sacct Duration `json:"sacct,omitzero"`
Kubernetes Duration `json:"kubernetes,omitzero"`
}
Timeouts bounds commands that carry no bound of their own. Sacct bounds each sacct call on the Slurm host: a hung slurmdbd keeps its port open and sacct then waits indefinitely (spec 0002 D2). Kubernetes bounds each read of the Kubernetes source (D5).
Source Files
¶
- backend.go
- batch.go
- cache.go
- cause.go
- cessation.go
- classify.go
- config.go
- control.go
- ctldlog.go
- decode.go
- doc.go
- execfile.go
- extensions.go
- holds.go
- hook.go
- hostlist.go
- jobs.go
- keyset.go
- keyset_v0044_gen.go
- kubesource.go
- lostnodes.go
- manifest.go
- output.go
- parsable.go
- preflight.go
- probe.go
- progress.go
- quote.go
- requeue.go
- sacct.go
- schema.go
- showconfig.go
- start.go
- strictjson.go
- submit.go
- wrapper.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cmd/keysetgen
command
Command keysetgen derives the data_parser v0.0.44 key set of a squeue or `scontrol show job` response from the Slurm source, and writes it as Go.
|
Command keysetgen derives the data_parser v0.0.44 key set of a squeue or `scontrol show job` response from the Slurm source, and writes it as Go. |
|
hook
Package hook carries seams the module's own test harnesses need and the public API does not offer.
|
Package hook carries seams the module's own test harnesses need and the public API does not offer. |
|
privatedir
Package privatedir creates and checks directories only their owner may reach.
|
Package privatedir creates and checks directories only their owner may reach. |
|
sind
Package sind stands up a sind Slurm cluster in docker and injects the faults go/dispatch's conformance suite asks for, so the adapter can be checked against a real slurmctld (spec 0001, Testing).
|
Package sind stands up a sind Slurm cluster in docker and injects the faults go/dispatch's conformance suite asks for, so the adapter can be checked against a real slurmctld (spec 0001, Testing). |
|
Package kube is the Slurm adapter's read-only client of the Kubernetes API: a pod, the slurmctld log, and whether the adapter's credential may read each (spec 0002 D5).
|
Package kube is the Slurm adapter's read-only client of the Kubernetes API: a pod, the slurmctld log, and whether the adapter's credential may read each (spec 0002 D5). |
|
Package slurmtest replays recorded transcripts in place of a Slurm host, for the adapter's own tests and for consumers' tests: an Executor that answers each script with its recorded Result, and fixtures that render Slurm's v0.0.44 job JSON from captures.
|
Package slurmtest replays recorded transcripts in place of a Slurm host, for the adapter's own tests and for consumers' tests: an Executor that answers each script with its recorded Result, and fixtures that render Slurm's v0.0.44 job JSON from captures. |
|
Package transport is the seam between the Slurm adapter's meaning and the delivery of its scripts to the Slurm host: the Executor contract, Script and Result, and the output framing every transport shares.
|
Package transport is the seam between the Slurm adapter's meaning and the delivery of its scripts to the Slurm host: the Executor contract, Script and Result, and the output framing every transport shares. |
|
local
Package local runs the Slurm adapter's scripts on this host, for a supervisor that runs on a login node.
|
Package local runs the Slurm adapter's scripts on this host, for a supervisor that runs on a login node. |
|
ssh
Package ssh runs the Slurm adapter's scripts on a login node through the OpenSSH client binary, which brings the user's agent, keys, ssh_config, ControlMaster and site two-factor setups unchanged.
|
Package ssh runs the Slurm adapter's scripts on a login node through the OpenSSH client binary, which brings the user's agent, keys, ssh_config, ControlMaster and site two-factor setups unchanged. |