cluster

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: GPL-3.0, LGPL-3.0 Imports: 36 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cluster provides types and operations for sind cluster management.

CreateInRealm, Create, Delete, DeleteAll, WorkerAdd, WorkerRemove, Connect, Disconnect, PowerOn, PowerReboot and PowerCycle change state that every cluster of a realm shares and take no lock themselves: their caller holds the realm lock, state.LockRealm with the docker client as LockOptions.Client, for the whole operation. A cluster is created with CheckDaemon, the lock and CreateInRealm.

Index

Examples

Constants

View Source
const (
	PositionPrimary = "primary"
	PositionBackup  = "backup"
)

Controller positions in a primary/backup pair, matching the order of the SlurmctldHost lines and the labels scontrol ping uses.

View Source
const (
	LabelRealm        = "sind.realm"
	LabelCluster      = "sind.cluster"
	LabelRole         = "sind.role"
	LabelManaged      = "sind.managed"
	LabelSlurmVersion = "sind.slurm.version"
	// LabelDataHostPath records the host directory the node bind-mounts as
	// its data (storage.dataStorage.hostPath), empty for the cluster's data
	// volume.
	LabelDataHostPath = "sind.data.hostpath"
	// LabelDataMountPath records the data mount point
	// (storage.dataStorage.mountPath, DefaultDataMountPath by default).
	LabelDataMountPath = "sind.data.mountpath"
	// LabelCVMFS records how the node mounts CVMFS (storage.cvmfs): "volume"
	// for the cvmfs volume plugin, "hostPath" for the Docker host's /cvmfs,
	// empty for none.
	LabelCVMFS = "sind.cvmfs"
	// LabelUsers and LabelGroups record the cluster users and groups
	// (users, groups), as space-separated entries (see linuxUsers.Labels).
	LabelUsers  = "sind.users"
	LabelGroups = "sind.groups"
	// LabelIdentity records the identity mode (identity) of the cluster:
	// local, nssSlurm or clientIds.
	LabelIdentity = "sind.identity"
	// LabelMonitoring records whether the node's cluster is monitored
	// (monitoring): "true" or "false". It is for listings and filters
	// only: an image could carry it too, so what decides is the node's
	// mount of the realm's journal volume (see monitored).
	LabelMonitoring = "sind.monitoring"
)

Label keys used on sind containers.

Docker merges the image's labels into a container's, so a label sind leaves out can come from the image. Every node container therefore gets each of these labels, with an empty value where there is nothing to record, and readers treat an empty or missing label alike, as nodes created by earlier sind versions lack some of them.

View Source
const (
	// CVMFSPath is where the nodes mount CVMFS, and where the Docker host
	// has it for the bind mount.
	CVMFSPath = "/cvmfs"
)

CVMFS on the nodes (storage.cvmfs).

View Source
const ControllerBackupShortName = slurm.BackupControllerHost

ControllerBackupShortName is the hostname of the backup controller created when the controller node spec sets backupController: true. It matches the second SlurmctldHost line in the generated slurm.conf.

View Source
const DNSSuffix = "sind"

DNSSuffix is the base domain for all sind DNS names.

View Source
const DefaultDataMountPath = "/data"

DefaultDataMountPath is the default mount path for the shared data volume.

View Source
const DefaultReadinessInterval = probe.DefaultInterval

DefaultReadinessInterval is the delay between readiness probe rounds that Create, WorkerAdd and WaitNodes use for an Interval of zero or less.

View Source
const HomeMountPath = "/home"

HomeMountPath is where the nodes of a cluster with users mount the cluster's home volume, which holds the users' home directories.

View Source
const RollbackTimeout = 5 * time.Minute

RollbackTimeout bounds the rollback of a failed Create or WorkerAdd, and the removal of a mesh that sind create cluster could not finish. The writes that must not be cut short (detach.Context) have the same bound outside a rollback. The rollback runs on a context that ignores the caller's cancellation (an interrupted create still cleans up), so without a bound a hung Docker daemon would hold it forever; what is left then is reported.

View Source
const ServiceMissing docker.ContainerState = "missing"

ServiceMissing is the status of a monitoring service whose container does not exist.

Variables

View Source
var (
	// ErrClusterExists reports that resources with the names of the
	// cluster to create exist already (preflightCheck, Create).
	ErrClusterExists = errors.New("cluster resources exist")
	// ErrClusterNotFound reports that a cluster, or its controller, does
	// not exist in the realm: GetStatus, GetNodes, GetNode, GetAuthKey,
	// EnterTarget, GetSlurmInfo, CheckNode, WaitNodes, WorkerAdd,
	// WorkerRemove and the Power functions, among others. Delete returns
	// nil instead.
	ErrClusterNotFound = errors.New("cluster not found")
	// ErrNodeNotFound reports that a named node does not exist in its
	// cluster: GetNode, CheckNode, NodeServices, WaitNodes, WorkerRemove
	// and the Power functions, among others.
	ErrNodeNotFound = errors.New("node not found")
	// ErrNodesConfMissing reports that the controller has no
	// sind-nodes.conf, so sind cannot add managed workers (WorkerAdd);
	// unmanaged ones (WorkerAddOptions.Unmanaged) leave the Slurm
	// configuration alone.
	ErrNodesConfMissing = errors.New("sind-nodes.conf not found on controller: managed workers require sind-generated Slurm configuration")
	// ErrNotReady reports that the nodes or Slurm of a Create or WorkerAdd
	// did not become ready within its wait limit (config.Cluster.Wait,
	// WorkerAddOptions.Wait).
	ErrNotReady = errors.New("not ready")
	// ErrNetworkFull reports that the nodes of a Create or WorkerAdd do
	// not fit on the realm's mesh or the cluster network, Docker bridge
	// networks of at most docker.MaxBridgeEndpoints containers
	// (preflightCheck, Create, WorkerAdd).
	ErrNetworkFull = errors.New("network full")
	// ErrImageUnsupported reports that a monitored cluster's image cannot
	// serve the HTTP endpoints the monitoring stack uses: a Slurm older
	// than slurm.MonitoringMinVersion, or a missing plugin (Create,
	// WorkerAdd).
	ErrImageUnsupported = errors.New("image unsupported")
	// ErrNoMonitoring reports that the realm has no monitoring stack
	// (GetMonitoring).
	ErrNoMonitoring = errors.New("no monitoring stack")
)

Errors that library callers can test for with errors.Is. The errors pkg/cluster returns wrap them and carry their own message.

The rule for the two not-found sentinels: a function that takes the name of a cluster that must exist fails with an error that wraps ErrClusterNotFound when the realm holds no such cluster, and one that takes node names fails with ErrNodeNotFound for a node the cluster does not have. WorkerRemove follows the rule too. The exceptions: Delete of a cluster that does not exist is no error, and NodeServices, which takes one node, reports a missing cluster as a missing node.

View Source
var (
	// ErrRootlessDaemon is a daemon in rootless mode.
	ErrRootlessDaemon = errors.New("the Docker daemon runs in rootless mode")
	// ErrUsernsRemap is a daemon that remaps user namespaces.
	ErrUsernsRemap = errors.New("the Docker daemon runs with userns-remap")
	// ErrCgroupV1 is a daemon that runs containers on cgroup v1.
	ErrCgroupV1 = errors.New("the Docker daemon runs containers on cgroup v1")
	// ErrDockerTooOld is a Docker Engine older than 28.0.
	ErrDockerTooOld = errors.New("the Docker Engine is too old")
	// ErrDockerCLITooOld is a docker CLI older than 28.0.
	ErrDockerCLITooOld = errors.New("the docker CLI is too old")
	// ErrNoNsdelegate is a Docker host whose cgroup2 hierarchy is mounted
	// without nsdelegate (CheckNsdelegate).
	ErrNoNsdelegate = errors.New("the Docker host mounts cgroup2 without nsdelegate")
)

The errors DaemonSupport wraps for a Docker daemon that cannot run sind nodes.

AllVolumeTypes lists the cluster volume types in creation order.

AuthTypes are the authentication types GetAuthKey takes.

Functions

func AddSlurmStates added in v0.17.0

func AddSlurmStates(ctx context.Context, client *docker.Client, status *Status)

AddSlurmStates sets the Slurm state of the managed workers of status (NodeHealth.Slurm), from one sinfo on the controller in control: the primary controller while it runs, else the backup (see findController). GetStatus leaves it out, so that a slurmctld that is slow to answer does not hold up the status. A cluster without a running controller, or a sinfo that fails or does not answer within slurmInfoTimeout, leaves the states unset, with a debug log line that says why.

func CheckDaemon added in v0.11.0

func CheckDaemon(ctx context.Context, client *docker.Client) error

CheckDaemon asks the Docker daemon what it is and returns DaemonSupport's verdict, with a pointer to `sind doctor`. Call it before mesh.Manager.EnsureMesh and Create, so that an unsupported daemon fails before anything is pulled or created.

func CheckNode added in v0.13.0

func CheckNode(ctx context.Context, client *docker.Client, realm, clusterName, shortName string) error

CheckNode fails with an error that wraps ErrClusterNotFound for a cluster that has no containers in the realm, and ErrNodeNotFound for a node the cluster does not hold. The commands that hand a node to docker, logs and ssh, call it first: docker's own error would name an internal container.

func CheckNsdelegate added in v0.11.0

func CheckNsdelegate(ctx context.Context, client *docker.Client, image string) error

CheckNsdelegate reads the cgroup2 mount of the Docker daemon's kernel in a throwaway container of image (doctor.ProbeCgroupInfo), and returns an error that wraps ErrNoNsdelegate, with the commands that enable it, when the mount lacks nsdelegate, or ErrCgroupV1 when the container has no cgroup2 at doctor.CgroupRoot. Unlike `sind doctor` for a daemon on this machine, it looks at the daemon's kernel wherever that runs. Create and WorkerAdd call it before they create a node container: without nsdelegate the failure would show only later, as a node or Slurm daemon that does not become ready.

func Connect added in v0.13.0

func Connect(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, names ...docker.ContainerName) error

Connect attaches containers outside sind to the realm's mesh network and every cluster network, skipping the ones they already join. Create connects them to the network of a cluster created later as well, while they are on the mesh network. It fails for a realm without mesh, and for a container that does not exist or is sind's own.

The caller holds the realm lock (state.LockRealm) until Connect returns, so that a cluster create does not add a network meanwhile.

The attaching is the progress step "connecting", with a target for each container, one for a container named twice, named by it and announced queued before the first runs; one that joins every network already is skipped as "connected". The first container that fails ends the step, and the targets not yet tried end canceled with it.

func Connectable added in v0.16.0

func Connectable(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager) ([]docker.ContainerListEntry, error)

Connectable returns what docker ps says of the containers that ConnectableContainers names, sorted by name, running or not.

func ConnectableContainers added in v0.13.0

func ConnectableContainers(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager) ([]docker.ContainerName, error)

ConnectableContainers returns the containers outside sind that are not attached to the realm's mesh network, sorted: those Connect can attach.

func ContainerName

func ContainerName(realm, cluster, shortName string) docker.ContainerName

ContainerName returns the Docker container name for a node. shortName is the node's hostname, e.g. "controller", "db", "api", "submitter", "worker-0".

func ContainerPrefix

func ContainerPrefix(realm, cluster string) string

ContainerPrefix returns the container name prefix for a cluster, used to extract short names from full container names.

func Create

func Create(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, cfg *config.Cluster, opts CreateOptions) (retErr error)

Create orchestrates the full cluster creation flow, in a realm whose mesh exists: CreateInRealm sets it up first.

The caller holds the realm lock (state.LockRealm) from before mesh.Manager.EnsureMesh until Create returns, and checks the daemon with CheckDaemon before either.

Create applies the config's defaults (config.Cluster.ApplyDefaults) to cfg and validates it first, and refuses a meshMgr.Realm, the realm it creates the cluster in, that config.CheckName refuses, and a config realm other than it. The context deadline controls the overall timeout, except for the writes of the mesh DNS, known_hosts and sind-nodes.conf, which ignore it so that they are not cut short, and may outlive it by up to RollbackTimeout; opts.Interval controls the polling interval for readiness probes, and zero or less means DefaultReadinessInterval. cfg.Wait, when positive, limits how long Create waits for the nodes and Slurm to become ready, counted for each node from when its container has started, so that image pulls do not count; the steps after the nodes are ready end cfg.Wait after the last node container started. When the limit is reached, Create rolls back and returns an error that wraps ErrNotReady.

┌ preflightCheck → createResources ─────────────────┐
├ resolveInfra (DNS IP ║ SSH key ║ Slurm version) ──┤  (version from the image probe with monitoring)
├ detectCVMFS (storage.cvmfs only) ─────────────────┼→ setupNodes
├ CheckNsdelegate ──────────────────────────────────┤
└ pullImages (missing images; all with cfg.Pull) ───┘
                        │
registerNodes ║ enableSlurm → createSlurmAccounts (accounts only) ║ createHomes (users only) ║ ensureMonitoring (monitoring only)
                        │
              registerStackDNS (monitoring only)
                        │
                    *Cluster

Each distinct image the daemon does not have, or with cfg.Pull each distinct image, is pulled once, concurrently, and the steps that run one (the helpers of createResources, the Slurm version, detectCVMFS, CheckNsdelegate) wait for the pull; nothing is created with --pull always, and no node container's docker create pulls (see startPull). A failed check rolls back what the other branches have created by then; no node container exists yet.

A monitored cluster (monitoring) gets its images probed for the HTTP endpoints the monitoring stack scrapes, which also gives the Slurm version, the stack's images pulled, its nodes' journal directories made, and in the last phase the realm's monitoring stack created or started and synced with the new nodes, and slurmctld's HTTP endpoints checked once it is ready. A failed create removes the stack when it made it and no other cluster of the realm is monitored.

An unmanaged cluster (managed: false on the controller) gets the same containers, volumes and munge key, but sind writes no Slurm configuration, does not discover the Slurm version and enables no Slurm daemon.

func CreateInRealm added in v0.18.0

func CreateInRealm(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, cfg *config.Cluster, opts CreateOptions) error

CreateInRealm creates the cluster of cfg in the realm of meshMgr with the step that Create needs first: it sets up the realm's mesh (mesh.Manager.EnsureMesh, which pulls its images with meshMgr.Pull) and, when that fails, removes a mesh it made, as the progress step "rollback", on a context that ignores the end of ctx and that RollbackTimeout bounds; a failure of that removal is joined to the error. Then it runs Create, whose rollback removes the mesh as well when this call made it and no other cluster uses it.

It applies the config's defaults and checks the config and the realm as Create does before the mesh, so that a config that Create refuses sets up nothing.

The caller checks the daemon with CheckDaemon, so that an unsupported one fails before anything is pulled, and holds the realm lock (state.LockRealm, with client as LockOptions.Client) until CreateInRealm returns: a mesh.Manager is not safe for concurrent use, and the lock is what keeps two commands from changing the realm's mesh at once.

Example

ExampleCreateInRealm creates a cluster as sind create cluster does: it checks the daemon before it takes the realm lock, holds the lock for the whole change, creates the cluster with its mesh, and brings the realm's SSH config export up to date.

// SPDX-License-Identifier: LGPL-3.0-or-later

package main

import (
	"cmp"
	"context"
	"fmt"
	"log"
	"os"
	"time"

	"github.com/spf13/afero"

	"github.com/GSI-HPC/sind/pkg/cluster"
	"github.com/GSI-HPC/sind/pkg/cmdexec"
	"github.com/GSI-HPC/sind/pkg/config"
	"github.com/GSI-HPC/sind/pkg/docker"
	"github.com/GSI-HPC/sind/pkg/mesh"
	"github.com/GSI-HPC/sind/pkg/state"
)

// ExampleCreateInRealm creates a cluster as sind create cluster does: it
// checks the daemon before it takes the realm lock, holds the lock for the
// whole change, creates the cluster with its mesh, and brings the realm's
// SSH config export up to date.
func main() {
	if err := createCluster(context.Background(), "cluster.yaml"); err != nil {
		log.Fatal(err)
	}
}

// createCluster creates the cluster of the config file path.
func createCluster(ctx context.Context, path string) error {
	data, err := os.ReadFile(path)
	if err != nil {
		return err
	}
	// Parse reads the config; Create applies its defaults and validates it.
	cfg, err := config.Parse(data)
	if err != nil {
		return err
	}
	for _, w := range cfg.Warnings() {
		fmt.Fprintln(os.Stderr, "Warning:", w)
	}
	// The cluster's realm: the config's, else the default realm.
	realm := cmp.Or(cfg.Realm, mesh.DefaultRealm)
	cfg.Realm = realm
	// Create waits for the nodes and Slurm to become ready, as sind create
	// cluster --wait does.
	cfg.Wait = 5 * time.Minute

	client := docker.NewClient(&cmdexec.OSExecutor{})
	// A daemon that cannot run sind nodes fails here, before the caller
	// waits for the lock of another.
	if err := cluster.CheckDaemon(ctx, client); err != nil {
		return err
	}
	// The realm lock serializes the changes of sind processes and other
	// clients of the daemon; Create takes none itself.
	unlock, err := state.LockRealm(ctx, realm, &state.LockOptions{Client: client})
	if err != nil {
		return err
	}
	defer unlock()

	// CreateInRealm sets up the realm's mesh, removes a mesh it made when
	// that fails, and creates the cluster; Create alone needs a mesh that
	// is set up already.
	meshMgr := mesh.NewManager(client, realm)
	if err := cluster.CreateInRealm(ctx, client, meshMgr, cfg, cluster.CreateOptions{}); err != nil {
		return err
	}
	// The SSH config export in the state directory, for ssh -F.
	if err := cluster.ExportSSHConfig(ctx, client, afero.NewOsFs(), realm); err != nil {
		fmt.Fprintln(os.Stderr, "Warning: could not update SSH config:", err)
	}
	return nil
}

func DNSName

func DNSName(shortName, cluster, realm string) string

DNSName returns the fully qualified DNS name for a node. shortName is the node's hostname, e.g. "controller", "worker-0".

func DaemonSupport added in v0.11.0

func DaemonSupport(info *docker.DaemonInfo) error

DaemonSupport returns nil when the daemon that info describes can run sind nodes. Every node starts with --security-opt writable-cgroups=true, which Docker refuses on a daemon in rootless mode or with userns-remap, and only at `docker start`: after the images are pulled and the cluster's network and volumes created. A node's entrypoint and systemd need cgroup v2; on cgroup v1 the node never becomes ready. Docker Engines before 28.0 know neither writable-cgroups nor the gw-priority of the nodes' network endpoints, and refuse every node at `docker create`; so does a docker CLI before 28.0, which parses the gw-priority itself, and one before 24.0, whose docker info has no version (docker.OldClientVersion). A version that does not parse, or a docker info without ClientInfo, passes, as `sind doctor` reports it.

func DataPathWarning added in v0.11.0

func DataPathWarning(hostPath string) string

DataPathWarning returns a warning when a cluster's data host path is the host's root directory or the user's home directory ($HOME), which every node then mounts read-write: typically by accident, from sind create cluster run there with the default --data . It returns "" for any other path.

func Delete

func Delete(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, clusterName string) error

Delete orchestrates the full cluster deletion flow.

The caller holds the realm lock (state.LockRealm) until Delete returns.

Deleting a non-existent cluster is not an error. The function handles partial clusters (e.g., from a failed creation) by removing whatever resources exist.

hasOtherClusters?
      │
deleteClusterResources   deregisters from the mesh and the monitoring stack only if other clusters remain
      │
    yes → done
    no  → cleanupRealm (monitoring stack containers → stack volumes → mesh)

Whether other clusters remain does not depend on this cluster's containers, so Delete settles it first: when the mesh goes too, removing the nodes' DNS records and known_hosts entries would be wasted work.

The mesh is what makes a container one of the realm's external containers (see ExternalContainers). Removing it detaches them, so a cluster created later is not connected to them: Delete then names them through meshMgr.Warn, also those that the removal of the mesh detached before it failed (see detachedExternal), as a retry no longer finds them on the mesh.

func DeleteAll added in v0.11.0

func DeleteAll(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager) error

DeleteAll deletes every cluster of the realm, in parallel, and then the realm's mesh. It finds the clusters by the labels of their containers, networks and volumes, and removes the mesh even when it finds no cluster: a create that was killed can leave a mesh behind without one.

A cluster that fails to delete does not stop the others. The mesh then stays for what is left, the clusters that were deleted are deregistered from it, and so are the nodes of a cluster that failed after it listed them, as Delete deregisters them before it removes any (see deregisterClusters). DeleteAll returns the failures, joined. Once ctx has ended no further cluster is tried, and those left out fail with the context's error, worded as "deleting cluster <name>: listing containers: <err>", as when they were tried and failed at their first lookup; the deregistration then still runs, as cleanup, on a context that ignores the end of ctx (internal/detach), and the monitoring stack is not updated: the next delete does it. A panic while deleting a cluster becomes that cluster's error.

The clusters are the progress step "clusters", with a target for each (fanout.Map), under which each cluster's removal reports its steps as Delete does; the realm's the steps "monitoring stack", "monitoring volumes" and "mesh".

func Disconnect added in v0.13.0

func Disconnect(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, names ...docker.ContainerName) error

Disconnect detaches containers outside sind from every network of the realm they join. A container that joins none is left as it is. It fails for a container that does not exist or is sind's own.

The caller holds the realm lock (state.LockRealm) until Disconnect returns, so that a cluster create does not add a network meanwhile.

The detaching is the progress step "disconnecting", reported as the step of Connect is, with a container that joins no network skipped as "not connected".

func DiscoverClusterNames added in v0.3.0

func DiscoverClusterNames(ctx context.Context, client *docker.Client, realm string) ([]string, error)

DiscoverClusterNames finds cluster names from orphaned networks and volumes that may not have containers. This supplements GetClusters (which only finds clusters with running containers) for cleanup operations.

Filters on both the realm and cluster labels so mesh resources (which carry only the realm label) are skipped, and resources from other realms can't match even when names collide. The network and volume listings run concurrently. The names come back sorted, and nil when there are none.

func EnterTarget

func EnterTarget(ctx context.Context, client *docker.Client, realm, clusterName string) (target, workDir string, err error)

EnterTarget determines the target node for sind enter and sind exec, and the directory they start in: the node's data mount point. The target is "submitter" if present in the cluster, otherwise the controller: in a primary/backup pair the one in control, falling back to "controller" when that cannot be determined. In an unmanaged cluster sind does not know which controller is in control, so the running one is picked, preferring "controller".

func ExportSSHConfig added in v0.18.0

func ExportSSHConfig(ctx context.Context, client *docker.Client, fs afero.Fs, realm string) error

ExportSSHConfig brings the realm's SSH config export in its state directory (state.RealmDir) up to date in fs: ssh_config, id_ed25519 and known_hosts, read from the realm's SSH relay in one docker exec, each replaced through a temporary file and a rename. When the relay container does not exist, the realm has no cluster: it removes the files, and the directory if that leaves it empty. The sind CLI runs it after every command that changes the realm's clusters; GetSSHConfig returns the path of the ssh_config.

func ExternalContainers added in v0.13.0

func ExternalContainers(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager) ([]docker.ContainerName, error)

ExternalContainers returns the containers outside sind attached to the realm's mesh network, sorted. A realm without mesh has none.

func GetNodeNames added in v0.11.0

func GetNodeNames(ctx context.Context, client *docker.Client, realm string, roles ...config.Role) ([]string, error)

GetNodeNames returns the nodes of every cluster in the realm as NODE.CLUSTER, ordered by cluster name, then like GetNodes, only those of roles when any are given. It lists the realm's containers once and inspects none, for shell completion.

func HomeDir added in v0.11.0

func HomeDir(user string) string

HomeDir returns the home directory of a cluster user.

func NetworkName

func NetworkName(realm, cluster string) docker.NetworkName

NetworkName returns the Docker network name for a cluster.

func NodeNameSuffix added in v0.18.0

func NodeNameSuffix(cluster string) string

NodeNameSuffix returns what follows the short name of a node of the cluster where sind names it as its node arguments take it: "." and the cluster, or nothing in the default cluster.

func NodeServices added in v0.13.0

func NodeServices(ctx context.Context, client *docker.Client, realm, clusterName, shortName string) ([]string, error)

NodeServices returns the systemd units of a node whose journal `sind logs` shows, by name: those get node checks on it, which depend on its role and on whether sind manages Slurm on it. It inspects the node's container, for shell completion; a container whose labels name another realm or cluster (see ownedBy), or a helper (see isNode), is not the node. A node without such a container fails with ErrNodeNotFound, also when the cluster does not exist; for a node without a container the error wraps docker's too (docker.IsNotFound).

func PowerCut

func PowerCut(ctx context.Context, client *docker.Client, realm, clusterName string, shortNames []string) error

PowerCut immediately kills the specified nodes (docker kill). A node that does not run counts as killed, as PowerShutdown counts it stopped.

func PowerCycle

func PowerCycle(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, clusterName string, shortNames []string) error

PowerCycle hard-restarts the specified nodes: it kills them all (docker kill), then starts them as PowerOn does. A node that does not run is started, as PowerReboot starts it.

func PowerFreeze

func PowerFreeze(ctx context.Context, client *docker.Client, realm, clusterName string, shortNames []string) error

PowerFreeze suspends all processes in the specified nodes (docker pause). The containers remain running but are completely unresponsive.

func PowerOn

func PowerOn(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, clusterName string, shortNames []string) error

PowerOn starts the specified stopped nodes (docker start). It first starts the realm's mesh DNS and SSH relay if they are stopped, as after a host reboot, and afterwards points the started nodes' mesh DNS records at their addresses: Docker can give a node another address each time it starts. It adds the host keys of started nodes that the relay's known_hosts lacks (see addMissingHostKeys). A stopped monitoring stack of the realm starts with the nodes; one that cannot start or get ready fails the call when the cluster is monitored, and is a warning (meshMgr.Warn) when it is not.

func PowerReboot

func PowerReboot(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, clusterName string, shortNames []string) error

PowerReboot gracefully restarts the specified nodes: it stops them all (docker stop), then starts them as PowerOn does.

func PowerShutdown

func PowerShutdown(ctx context.Context, client *docker.Client, realm, clusterName string, shortNames []string) error

PowerShutdown gracefully stops the specified nodes (docker stop).

func PowerUnfreeze

func PowerUnfreeze(ctx context.Context, client *docker.Client, realm, clusterName string, shortNames []string) error

PowerUnfreeze resumes the specified frozen nodes (docker unpause).

func QualifiedNodeName added in v0.18.0

func QualifiedNodeName(cluster, shortName string) string

QualifiedNodeName returns the name of a node as sind's node arguments take it: the short name, and the cluster unless it is the default one, e.g. "worker-0" or "worker-0.dev".

func SlurmConfFiles added in v0.13.0

func SlurmConfFiles(cfg *config.Cluster) (slurmConf, nodesConf string, err error)

SlurmConfFiles returns slurm.conf and sind-nodes.conf as writeClusterConfig writes them for cfg, after ApplyDefaults: what the New cluster page of sind ui shows before the cluster exists.

func UserNodes added in v0.18.0

func UserNodes(cfg *config.Cluster) []string

UserNodes returns the short names of the nodes of cfg that Create adds the cluster's users and groups to (UsersScript), in the order of the config, after ApplyDefaults. Which nodes get them depends on the identity mode and on whether sind manages the node.

func UsersScript added in v0.13.0

func UsersScript(cfg *config.Cluster) string

UsersScript returns the groupadd and useradd commands that sind create cluster runs on each node that gets the users of cfg (see UserNodes), after ApplyDefaults; "" for a cluster without users and groups.

func VolumeName

func VolumeName(realm, cluster string, volumeType VolumeType) docker.VolumeName

VolumeName returns the Docker volume name for a cluster resource.

func WaitNodes added in v0.17.0

func WaitNodes(ctx context.Context, client *docker.Client, realm, clusterName string, shortNames []string, opts WaitOptions) (err error)

WaitNodes waits until nodes of a cluster that exist, by their short names, each once, are ready, as Create and WorkerAdd wait for the nodes they make: each node's container runs, systemd has booted, and the node's services are ready (sshd, munge but with identity clientIds, and where sind manages Slurm the node's Slurm daemon, see nodeServices); then slurmctld has the registration of each managed worker among nodes, as sinfo on the controller in control tells (probe.WorkersRegistered). The power commands that start nodes call it with --wait.

opts.Wait bounds the whole wait; zero or less sets no limit. When the limit ends it, the error wraps ErrNotReady. A container that exits, or a unit that fails, ends the wait at once, as in Create. Managed workers need a running controller to register with: without one the wait fails at once. opts.Interval is the delay between probe rounds, as for Create.

The wait is the progress step "readiness", with a target for each node, named as the power commands name it (QualifiedNodeName), and, after them, the wait for the workers' registration. Every error names the cluster, so that the joined errors of several clusters tell them apart: that of a node by its QualifiedNodeName.

func WithPanicLog added in v0.12.0

func WithPanicLog(ctx context.Context, w io.Writer) context.Context

WithPanicLog returns ctx with w as where the pools of the power commands and of DeleteAll write the line and the stack of a panic in the work for one node or cluster while ctx carries no progress Bus, as the command's stderr: with a Bus, they write them to its PanicLog, which a display shows above itself; with neither, to the process's standard error.

func WorkerRemove

func WorkerRemove(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, clusterName string, shortNames []string) error

WorkerRemove removes worker nodes from a cluster.

The caller holds the realm lock (state.LockRealm) until WorkerRemove returns.

For managed nodes (those present in sind-nodes.conf), the flow is:

  1. Read sind-nodes.conf through the controller, which has to run
  2. Update sind-nodes.conf to remove the node definitions and reconfigure slurmctld
  3. Deregister DNS + known_hosts
  4. Stop + remove containers
  5. On a monitored cluster, sync the monitoring stack and remove the workers' journal directories (see forgetMonitoredNodes)

For unmanaged nodes, and every node of an unmanaged cluster, steps 1 and 2 are skipped: the Slurm configuration of an unmanaged cluster is the user's, even if it contains a sind-nodes.conf. So is a configuration without sind-nodes.conf.

A worker that sind-nodes.conf of a managed cluster still defines but whose container is gone (left by a rollback of WorkerAdd that could not restore the file, or by a container removed outside sind) is removed from the file and from the mesh, with a warning (meshMgr.Warn). Any other name without a container fails with ErrNodeNotFound, and nothing is removed. So does one when sind-nodes.conf cannot be read, as with a stopped controller: the error then says why.

The steps it reports are "slurm" (the update of sind-nodes.conf and the reconfigure), then "mesh deregistration", "nodes" with a target for each worker, and "monitoring" on a monitored cluster.

Types

type AuthKey added in v0.11.0

type AuthKey struct {
	Type AuthType
	Key  []byte
}

AuthKey is a key that authenticates a cluster's Slurm traffic.

func GetAuthKey added in v0.11.0

func GetAuthKey(ctx context.Context, client *docker.Client, realm, clusterName string, authType AuthType) (*AuthKey, error)

GetAuthKey reads a key that authenticates a cluster's Slurm traffic from one of its node containers: for authType munge the munge key, for slurm slurm.key, with identity clientIds, and for jwt jwt_hs256.key, with a managed api node. An empty authType is the cluster's AuthType: slurm with identity clientIds, munge otherwise. A type the cluster does not use is an error that says why.

type AuthType added in v0.11.0

type AuthType string

AuthType is a Slurm authentication plugin a cluster uses, auth/<type>, and so which key GetAuthKey returns.

const (
	// AuthMunge is auth/munge: munged on every node, with the munge key.
	AuthMunge AuthType = "munge"
	// AuthSlurm is auth/slurm, with slurm.key, under identity clientIds.
	AuthSlurm AuthType = "slurm"
	// AuthJWT is auth/jwt, with jwt_hs256.key, the alternative
	// authentication of slurmrestd's tokens on a cluster with a managed api
	// node.
	AuthJWT AuthType = "jwt"
)

Authentication types.

type CreateOptions added in v0.18.0

type CreateOptions struct {
	// Interval is the delay between readiness probe rounds; zero or less
	// is DefaultReadinessInterval.
	Interval time.Duration
}

CreateOptions holds the options of Create that are not part of the cluster's config.

type HAStatus added in v0.10.0

type HAStatus struct {
	Position  string `json:"position"`   // "primary" or "backup"
	InControl bool   `json:"in_control"` // this controller currently runs the cluster
}

HAStatus describes a controller's place in a primary/backup pair.

type MonitoredCluster added in v0.12.0

type MonitoredCluster struct {
	Name         string       `json:"name"`
	Nodes        int          `json:"nodes"`
	SlurmVersion string       `json:"slurm_version"`
	Slurm        *SlurmCounts `json:"slurm,omitempty"` // nil while Prometheus has no numbers of the cluster
}

MonitoredCluster is a cluster the realm's monitoring stack collects.

type Monitoring added in v0.12.0

type Monitoring struct {
	Realm    string              `json:"realm"`
	Services []MonitoringService `json:"services"`
	Clusters []MonitoredCluster  `json:"clusters"`
}

Monitoring is the state of a realm's monitoring stack.

func GetMonitoring added in v0.12.0

func GetMonitoring(ctx context.Context, client *docker.Client, realm string) (*Monitoring, error)

GetMonitoring returns the state of the realm's monitoring stack: its services, and the clusters whose nodes mount the realm's journal volume, sorted by name, with their SlurmCounts while Grafana and Prometheus run and Prometheus has them. A realm without a stack fails with ErrNoMonitoring.

type MonitoringService added in v0.12.0

type MonitoringService struct {
	Name      string                `json:"name"` // grafana, prometheus, loki or alloy
	Container docker.ContainerName  `json:"container"`
	Image     string                `json:"image"`
	Interface string                `json:"interface"` // what its port serves: "web UI", "API" or "web UI + API"
	IP        string                `json:"ip"`        // on the mesh, empty while stopped
	URL       string                `json:"url"`       // by mesh DNS name; by IP for Alloy, which has none
	State     docker.ContainerState `json:"status"`    // the container's state, or ServiceMissing
	Ready     bool                  `json:"ready"`
	Checked   bool                  `json:"checked"` // whether Ready was checked, which needs Grafana running
}

MonitoringService is a service of the realm's monitoring stack.

type MountPoint added in v0.3.0

type MountPoint struct {
	Path    string             `json:"path"`              // mount path inside the container (e.g. "/etc/slurm")
	Source  string             `json:"source"`            // volume name or host path
	Subpath string             `json:"subpath,omitempty"` // the volume's directory the nodes mount theirs in, for the journal volume
	Type    config.StorageType `json:"type"`              // "volume" or "hostPath"
	OK      bool               `json:"ok"`                // true if the Docker volume exists (always true for hostPath)
	// Data marks the cluster's data mount, whatever its path
	// (storage.dataStorage.mountPath), for sind ui. The JSON output leaves
	// it out.
	Data bool `json:"-"`
}

MountPoint describes a volume or bind mount on cluster containers.

func GetMountPoints added in v0.3.0

func GetMountPoints(ctx context.Context, client *docker.Client, realm, clusterName string, containers []*docker.ContainerInfo) ([]MountPoint, error)

GetMountPoints returns the mount points for a cluster, checking volume existence for Docker volumes. containers are the cluster's node containers as docker inspect reports them, whose labels, unlike those docker ps lists, keep values with commas (see docker.ContainerInfo).

The data mount is what Docker mounts at a node's data mount point (the sind.data.mountpath label, or /data): a host-path bind mount or a Docker volume, the cluster's data volume when no node has one. The sind.users label adds the home volume at /home, and the sind.cvmfs label /cvmfs from the cvmfs plugin volume or the host's /cvmfs. With identity clientIds (the sind.identity label) there is no munge volume.

type NetworkHealth

type NetworkHealth struct {
	Mesh           bool   `json:"mesh_ok"`         // sind-mesh network exists
	MeshName       string `json:"mesh_name"`       // mesh network name (e.g. "sind-mesh")
	MeshDriver     string `json:"mesh_driver"`     // mesh network driver (e.g. "bridge")
	MeshSubnet     string `json:"mesh_subnet"`     // mesh network subnet
	MeshGateway    string `json:"mesh_gateway"`    // mesh network gateway
	DNS            bool   `json:"dns_ok"`          // sind-dns container running
	DNSName        string `json:"dns_name"`        // DNS container name (e.g. "sind-dns")
	SSH            bool   `json:"ssh_ok"`          // sind-ssh relay container running
	SSHName        string `json:"ssh_name"`        // SSH relay container name (e.g. "sind-ssh")
	Cluster        bool   `json:"cluster_ok"`      // cluster network exists
	ClusterName    string `json:"cluster_name"`    // cluster network name (e.g. "sind-dev-net")
	ClusterDriver  string `json:"cluster_driver"`  // cluster network driver (e.g. "bridge")
	ClusterSubnet  string `json:"cluster_subnet"`  // cluster network subnet
	ClusterGateway string `json:"cluster_gateway"` // cluster network gateway

	// The realm's monitoring stack, when it has one: whether each of its
	// services is ready; nil without a stack (see StackHealth).
	Grafana    *bool `json:"grafana_ok,omitempty"`
	Prometheus *bool `json:"prometheus_ok,omitempty"`
	Loki       *bool `json:"loki_ok,omitempty"`
	Alloy      *bool `json:"alloy_ok,omitempty"`
}

NetworkHealth holds the health and IPAM details of cluster networking.

func GetNetworkHealth

func GetNetworkHealth(ctx context.Context, client *docker.Client, realm, clusterName string) (*NetworkHealth, error)

GetNetworkHealth checks the health of mesh, DNS, SSH relay, and cluster networking, and of the realm's monitoring stack when it has one. The DNS and SSH relay containers count as healthy only while they run: after a host reboot they exist but are stopped. The stack's services count as healthy when they are ready.

func (*NetworkHealth) StackHealth added in v0.12.0

func (h *NetworkHealth) StackHealth() map[string]bool

StackHealth returns whether each service of the realm's monitoring stack is ready, keyed by the service's name ("grafana", "prometheus", "loki", "alloy"), as the fields Grafana, Prometheus, Loki and Alloy say; a service whose field is nil is left out, and so is every one without a stack.

type NetworkSummary

type NetworkSummary struct {
	Name    string `json:"name"`
	Driver  string `json:"driver"`
	Subnet  string `json:"subnet"`
	Gateway string `json:"gateway"`
}

NetworkSummary holds summary information about a sind network.

func GetNetworks

func GetNetworks(ctx context.Context, client *docker.Client, realm string) ([]*NetworkSummary, error)

GetNetworks lists all sind-related Docker networks with IPAM details. This includes per-cluster networks (sind-<cluster>-net) and the mesh network (sind-mesh), but not the realm lock (state.LockNetworkName), which carries the realm label while a command holds it.

type NodeDetail added in v0.9.0

type NodeDetail struct {
	Container string        `json:"container"`
	Cluster   string        `json:"cluster"`
	Role      config.Role   `json:"role"`
	Managed   bool          `json:"managed"` // sind manages Slurm on the node (see isManaged)
	FQDN      string        `json:"fqdn"`
	IP        string        `json:"ip"`
	State     State         `json:"status"`
	Services  ServiceHealth `json:"services"`
	HA        *HAStatus     `json:"ha,omitempty"` // controllers of a primary/backup pair only
	// Slurm is what slurmctld says about a managed worker, from a sinfo
	// on the controller in control; nil for other nodes, and when it is
	// not known, such as while no controller runs.
	Slurm *SlurmNodeState `json:"slurm,omitempty"`
}

NodeDetail holds the full identity and health information for a single node as reported by 'sind get node'. It has the fields of NodeSummary, by the same names, and adds Managed and a per-service health map; it does not embed NodeSummary, so that Managed keeps its place in the JSON. All readiness-checked services (munge, sshd, and on managed nodes the role's Slurm service, or mariadb and slurmdbd on a db node) are reported under Services.

func GetNode added in v0.13.0

func GetNode(ctx context.Context, client *docker.Client, realm, clusterName, shortName string) (*NodeDetail, error)

GetNode returns the identity and health of one node, for 'sind get node', with what slurmctld says about a managed worker (NodeDetail.Slurm). A node that does not exist, whose container's labels name another realm or cluster, or whose container is a helper (see isNode), fails with what CheckNode reports for a cluster without containers in the realm (ErrClusterNotFound), and otherwise with a "not found" error naming the node and its cluster.

type NodeHealth

type NodeHealth struct {
	State    State         `json:"status"`       // the node's state, from its container's (see containerStateToState)
	IP       string        `json:"ip"`           // container IP address
	Services ServiceHealth `json:"services"`     // all readiness-checked services (munge unless identity clientIds, sshd, and on managed nodes the role's slurmctld/slurmd, mariadb and slurmdbd, slurmrestd, or sackd)
	HA       *HAStatus     `json:"ha,omitempty"` // controllers of a primary/backup pair only
	// Slurm is what slurmctld says about a managed worker (see
	// AddSlurmStates); nil for other nodes, and when it is not known.
	Slurm *SlurmNodeState `json:"slurm,omitempty"`
}

NodeHealth holds the health status of a single node.

func GetNodeHealth

func GetNodeHealth(ctx context.Context, client *docker.Client, info *docker.ContainerInfo, role config.Role, realm, clusterName string) (*NodeHealth, error)

GetNodeHealth checks the health of a single node container, from its docker inspect result, which the caller already holds. If the container is not running, remaining checks are skipped and default to false. The role determines which Slurm service is checked; unmanaged nodes (see isManaged) get none. clusterName is used to select the cluster network IP.

type NodeStatus

type NodeStatus struct {
	Name    string      `json:"name"`    // DNS-style name: "controller.dev"
	Role    config.Role `json:"role"`    // "controller", "db", "api", "submitter", "worker"
	Managed bool        `json:"managed"` // sind manages Slurm on the node (see isManaged)
	Health  *NodeHealth `json:"health"`  //nolint:revive // nested health is intentional
}

NodeStatus combines node identity with health information.

type NodeSummary

type NodeSummary struct {
	Container string      `json:"container"` // Docker container name
	Cluster   string      `json:"cluster"`   // cluster name
	Role      config.Role `json:"role"`
	FQDN      string      `json:"fqdn"` // DNS name
	IP        string      `json:"ip"`   // container IP on cluster network
	State     State       `json:"status"`
}

NodeSummary holds summary information about a node in a sind cluster.

func GetAllNodes added in v0.9.0

func GetAllNodes(ctx context.Context, client *docker.Client, realm string) ([]*NodeSummary, error)

GetAllNodes lists all nodes across all clusters in the realm.

func GetNodes

func GetNodes(ctx context.Context, client *docker.Client, realm, clusterName string) ([]*NodeSummary, error)

GetNodes lists all nodes in the named cluster. A cluster that does not exist is an error (see ErrClusterNotFound), not an empty list.

func WorkerAdd

func WorkerAdd(ctx context.Context, client *docker.Client, meshMgr *mesh.Manager, opts WorkerAddOptions) (added []*NodeSummary, retErr error)

WorkerAdd adds worker nodes to an existing cluster and returns them, in the order of their names.

The caller holds the realm lock (state.LockRealm) until WorkerAdd returns.

For managed workers (default), the flow is:

  1. Validate: options, the realm name (config.CheckName), controller exists, room on the realm's mesh and the cluster network (see checkBridgePorts), sind-nodes.conf present
  2. Inspect the controller and the newest worker, for the cluster's settings and the new workers' shape
  3. Check an explicit image: its Slurm version, its identity support, and on a monitored cluster a managed worker's HTTP endpoint; meanwhile check the Docker host for nsdelegate (CheckNsdelegate) in a container of the controller's image
  4. On a monitored cluster, create or start the monitoring stack and make the workers' journal directories; create worker container(s)
  5. Wait for readiness, inject SSH keys, collect host keys
  6. Register DNS + known_hosts, while sind-nodes.conf gets the new nodes, slurmctld is reconfigured and slurmd starts on the new nodes

On a monitored cluster the workers then join the monitoring stack (see syncMonitoring).

For unmanaged workers (Unmanaged=true), the Slurm steps are skipped. Workers added to an unmanaged cluster are always unmanaged. A failure after the first container exists removes the new containers, mesh entries and NodeName lines again. As there, the writes of the mesh DNS, known_hosts and sind-nodes.conf ignore the end of ctx and may outlive it by up to RollbackTimeout.

func (*NodeSummary) ShortName added in v0.18.0

func (n *NodeSummary) ShortName() string

ShortName returns the node's name in its cluster, such as "worker-0": the first label of its DNS name.

type OptionError added in v0.18.0

type OptionError struct {
	Field string
	Err   error
}

OptionError reports an option that a call cannot act on (WorkerAddOptions.Check). Field is the option's field, such as "CPUs".

func (*OptionError) Error added in v0.18.0

func (e *OptionError) Error() string

Error returns the cause, which names the option.

func (*OptionError) Unwrap added in v0.18.0

func (e *OptionError) Unwrap() error

Unwrap returns the cause.

type RealmSummary added in v0.9.0

type RealmSummary struct {
	Name     string `json:"name"`
	Clusters int    `json:"clusters"`
}

RealmSummary holds summary information about a sind realm.

func GetRealms added in v0.9.0

func GetRealms(ctx context.Context, client *docker.Client) ([]*RealmSummary, error)

GetRealms lists all sind realms by querying Docker for containers with the sind.realm label. Containers are grouped by realm, and clusters are counted per realm.

type SSHConfig added in v0.13.0

type SSHConfig struct {
	Path   string `json:"path"`
	Exists bool   `json:"exists"`
}

SSHConfig is the SSH client configuration file of a realm, as reported by 'sind get ssh-config'.

func GetSSHConfig added in v0.13.0

func GetSSHConfig(fs afero.Fs, realm string) (*SSHConfig, error)

GetSSHConfig returns the path of the realm's ssh_config in the state directory and whether the file exists in fs. The path is also right before the file exists, for an Include; ExportSSHConfig writes the file, which the sind CLI runs after every command that changes the realm's clusters.

type ServiceHealth added in v0.7.0

type ServiceHealth map[string]bool

ServiceHealth maps the name of a readiness-checked service to its health status. The names are the systemd units of the services, such as munge, sshd, slurmd, slurmdbd, mariadb, sackd and slurmrestd, and slurmctld.

type SlurmCounts added in v0.13.0

type SlurmCounts struct {
	Nodes       int `json:"nodes"`
	NodesDown   int `json:"nodes_down"`
	NodesDrain  int `json:"nodes_drain"`
	JobsRunning int `json:"jobs_running"`
	JobsPending int `json:"jobs_pending"`
}

SlurmCounts are the key numbers of a monitored cluster, as slurmctld reports them to the realm's Prometheus: its nodes, those that are down and those that drain (a node can be both), and its running and pending jobs.

type SlurmFile added in v0.13.0

type SlurmFile struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

SlurmFile is a config file of the config volume.

type SlurmInfo added in v0.13.0

type SlurmInfo struct {
	Nodes      []SlurmNode      `json:"nodes"`
	Partitions []SlurmPartition `json:"partitions"`
	// Files are slurm.conf and sind-nodes.conf, the ones of them that the
	// controller could read. slurmdbd.conf holds a password and is not
	// read.
	Files []SlurmFile `json:"files"`
}

SlurmInfo is what Slurm itself says about a cluster: its nodes and partitions as sinfo reports them on the controller, and the Slurm config files that sind wrote.

func GetSlurmInfo added in v0.13.0

func GetSlurmInfo(ctx context.Context, client *docker.Client, realm, clusterName string) (*SlurmInfo, error)

GetSlurmInfo reads the cluster's slurm.conf and sind-nodes.conf on the controller in control, the primary while it runs, else the backup (see findController), and runs sinfo there, within slurmInfoTimeout. Both controllers mount the config volume. A controller that does not run, or a slurmctld that does not answer, is an error; the SlurmInfo then holds the files alone, which cat reads without slurmctld, and is nil when there are none. A file that cannot be read is left out. A cluster without containers and network fails with ErrClusterNotFound, as in GetStatus.

type SlurmNode added in v0.18.0

type SlurmNode struct {
	Name string `json:"name"`
	// State is sinfo's long state, such as idle, allocated, mixed,
	// drained or down; a "*" at its end means that the node does not
	// answer.
	State string `json:"state"`
	// Reason is why the node is down or drained, empty for none.
	Reason    string `json:"reason,omitempty"`
	CPUs      int    `json:"cpus"`
	AllocCPUs int    `json:"alloc_cpus"`
	MemoryMB  int    `json:"memory_mb"`
	// Partitions are the partitions of the node, in sinfo's order.
	Partitions []string `json:"partitions"`
}

SlurmNode is a node as sinfo reports it.

type SlurmNodeState added in v0.17.0

type SlurmNodeState struct {
	// State is sinfo's long state, such as idle, allocated, drained or
	// down; a "*" at its end means that the node does not answer.
	State string `json:"state"`
	// Reason is why the node is down or drained, empty for none.
	Reason string `json:"reason,omitempty"`
	// Registered tells whether slurmctld has the registration of the
	// node's slurmd and gets answers from it (slurm.NodeStateRegistered).
	Registered bool `json:"registered"`
}

SlurmNodeState is what slurmctld says about a managed worker, as sinfo reports it.

type SlurmPartition added in v0.18.0

type SlurmPartition struct {
	Name    string `json:"name"`
	Default bool   `json:"default"`
	// State is the availability: up, down, drain or inact.
	State     string `json:"state"`
	TimeLimit string `json:"time_limit"`
	Nodes     int    `json:"nodes"`
	// NodeList is the nodes as a host list, such as worker-[0-3].
	NodeList string `json:"node_list"`
}

SlurmPartition is a partition as sinfo reports it.

type State added in v0.2.0

type State string

State represents the state of a cluster or node.

const (
	StateRunning State = "running"
	StateStopped State = "stopped"
	StatePaused  State = "paused"
	StateMixed   State = "mixed"   // cluster: nodes in different states
	StateEmpty   State = "empty"   // cluster: no nodes exist
	StateUnknown State = "unknown" // node: unrecognised container state
)

Possible cluster/node states.

type Status

type Status struct {
	Realm        string         `json:"realm"`
	Name         string         `json:"name"`
	SlurmVersion string         `json:"slurm_version"`
	State        State          `json:"status"`
	Monitoring   bool           `json:"monitoring"` // the realm's monitoring stack collects the cluster (see monitored)
	Nodes        []*NodeStatus  `json:"nodes"`
	Network      *NetworkHealth `json:"network"`
	Mounts       []MountPoint   `json:"mounts"`
}

Status holds the full status of a sind cluster.

func GetStatus

func GetStatus(ctx context.Context, client *docker.Client, realm, clusterName string) (*Status, error)

GetStatus returns the full status of a cluster, aggregating node, network, and volume health information. A node whose container went away between the listing and the inspect, as one being deleted, is left out, unless all of them did.

func (*Status) NodeCounts added in v0.13.0

func (s *Status) NodeCounts() (running, stopped, paused int)

NodeCounts returns how many of the cluster's nodes are running, stopped and paused; every state but running and paused counts as stopped.

type Summary added in v0.2.0

type Summary struct {
	Name         string `json:"name"`
	SlurmVersion string `json:"slurm_version"`
	State        State  `json:"status"`
	NodeCount    int    `json:"nodes"`
	Submitters   int    `json:"submitters"`
	Controllers  int    `json:"controllers"`
	DBs          int    `json:"dbs"`
	APIs         int    `json:"apis"`
	Workers      int    `json:"workers"`
}

Summary holds summary information about a sind cluster.

func GetClusters

func GetClusters(ctx context.Context, client *docker.Client, realm string) ([]*Summary, error)

GetClusters lists all sind clusters by querying Docker for containers with the sind.cluster label. Containers are grouped by cluster name; a helper (see isNode) lists its cluster but is not counted as a node, so that a cluster an interrupted create left only a helper of shows as empty.

type VolumeSummary

type VolumeSummary struct {
	Name   string `json:"name"`
	Driver string `json:"driver"`
}

VolumeSummary holds summary information about a sind volume.

func GetVolumes

func GetVolumes(ctx context.Context, client *docker.Client, realm string) ([]*VolumeSummary, error)

GetVolumes lists all sind-related Docker volumes.

type VolumeType added in v0.7.0

type VolumeType string

VolumeType identifies a cluster volume kind.

const (
	VolumeConfig VolumeType = "config"
	VolumeMunge  VolumeType = "munge"
	VolumeData   VolumeType = "data"
	// VolumeState holds the slurmctld StateSaveLocation shared by the
	// primary and backup controller. Only clusters with a backup controller
	// have it.
	VolumeState VolumeType = "state"
	// VolumeHome holds the home directories of the cluster users. Only
	// clusters with users have it.
	VolumeHome VolumeType = "home"
)

Cluster volume types.

type WaitOptions added in v0.18.0

type WaitOptions struct {
	// Wait bounds the whole wait; zero or less sets no limit.
	Wait time.Duration
	// Interval is the delay between probe rounds; zero or less is
	// DefaultReadinessInterval.
	Interval time.Duration
}

WaitOptions holds the options of WaitNodes.

type WorkerAddOptions

type WorkerAddOptions struct {
	ClusterName string
	Count       int // 0 or less adds one worker
	Image       string
	CPUs        int
	Memory      string
	TmpSize     string
	Unmanaged   bool
	Pull        bool // pull Image first; needs Image
	// Wait, when positive, limits how long WorkerAdd waits for the new
	// workers to become ready, counted as for Create's config.Cluster.Wait.
	Wait time.Duration
	// Interval is the delay between readiness probe rounds; zero or less
	// is DefaultReadinessInterval.
	Interval    time.Duration
	CapAdd      []string
	CapDrop     []string
	Devices     []string
	SecurityOpt []string
}

WorkerAddOptions holds the parameters for adding worker nodes to a cluster. The image, resources and privileges are the new workers' shape: each one left at its zero value is taken from the cluster's newest worker (see workerShape). For the lists CapAdd, CapDrop, Devices and SecurityOpt, the zero value is nil: an empty list that is not nil replaces the newest worker's list too, so the new workers get none.

func (WorkerAddOptions) Check added in v0.11.0

func (o WorkerAddOptions) Check() error

Check reports the first option WorkerAdd cannot act on: a negative CPU count, a memory or /tmp size sind cannot read, Pull without Image, an unknown capability, a device path that is not absolute or an unknown security option, as an *OptionError that names the option by its field, such as WorkerAddOptions.CPUs. It calls docker for none of them, so that a caller can reject them before it takes the realm lock.

func (WorkerAddOptions) CheckNamed added in v0.18.0

func (o WorkerAddOptions) CheckNamed(name func(field string) string) error

CheckNamed is Check with the options named in its errors as name names them: a command line names its flags.

Jump to

Keyboard shortcuts

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