config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: GPL-3.0, LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config handles parsing and validation of sind cluster configuration.

Index

Constants

View Source
const (
	DefaultClusterName = "default"
	DefaultImage       = "ghcr.io/gsi-hpc/sind-node:latest"
	DefaultCPUs        = 1
	DefaultMemory      = "512m"
	DefaultTmpSize     = "256m"
)

Default resource values for cluster nodes.

Variables

This section is empty.

Functions

func CheckCapabilities added in v0.10.0

func CheckCapabilities(field string, caps []string) error

CheckCapabilities reports the first name in caps that is not a recognized Linux capability; field names the setting in the error, e.g. "capAdd".

func CheckDevices added in v0.10.0

func CheckDevices(devices []string) error

CheckDevices reports the first device whose host path is not absolute. A device is HOST_PATH[:CONTAINER_PATH[:PERMISSIONS]].

func CheckName added in v0.10.0

func CheckName(kind, name string) error

CheckName reports whether name may be used as a cluster or realm name; kind ("cluster" or "realm") names it in the error.

Both names become part of Docker resource names (<realm>-<cluster>-net), of DNS names (<node>.<cluster>.<realm>.sind) and of paths ($XDG_STATE_HOME/sind/<realm>), so each has to be one DNS label: lowercase ASCII letters, digits and hyphens, 1 to 63 characters, not beginning or ending with a hyphen. A "." would add a DNS label and split node arguments such as worker-0.dev in the wrong place, and "/" or ".." would leave the state directory. Uppercase letters are refused too: DNS ignores case, so Dev and dev would be two sets of containers behind the same DNS names.

Types

type Cluster

type Cluster struct {
	Kind     string   `json:"kind"`
	Name     string   `json:"name,omitempty"`
	Realm    string   `json:"realm,omitempty"`
	Defaults Defaults `json:"defaults,omitempty"`
	Storage  Storage  `json:"storage,omitempty"`
	Slurm    Slurm    `json:"slurm,omitempty"`
	Nodes    []Node   `json:"nodes,omitempty"`

	// Pull is a runtime flag (not part of the config file) that forces
	// fresh image pulls when creating containers.
	Pull bool `json:"-" yaml:"-"`
}

Cluster represents a sind cluster configuration.

func Parse

func Parse(data []byte) (*Cluster, error)

Parse parses a YAML cluster configuration and returns a Cluster.

func (*Cluster) ApplyDefaults

func (c *Cluster) ApplyDefaults()

ApplyDefaults populates missing fields with defaults. If no nodes are defined, creates a minimal cluster (1 controller + 1 worker). Node-level fields inherit from the Defaults section, which in turn falls back to built-in defaults.

func (*Cluster) HasBackupController added in v0.10.0

func (c *Cluster) HasBackupController() bool

HasBackupController reports whether the controller node spec enables the backup controller.

func (*Cluster) Managed added in v0.10.0

func (c *Cluster) Managed() bool

Managed reports whether sind manages the cluster's Slurm configuration and daemons. managed: false on the controller node spec makes the whole cluster unmanaged: sind writes no Slurm configuration and starts no Slurm daemons on any node.

func (*Cluster) Validate

func (c *Cluster) Validate() error

Validate checks that the cluster configuration satisfies all constraints. It should be called after ApplyDefaults.

type DataStorage

type DataStorage struct {
	Type      StorageType `json:"type,omitempty"`
	HostPath  string      `json:"hostPath,omitempty"`
	MountPath string      `json:"mountPath,omitempty"`
}

DataStorage configures the shared data volume.

func (DataStorage) UsesHostPath added in v0.10.0

func (d DataStorage) UsesHostPath() bool

UsesHostPath reports whether the data is a bind mount of HostPath rather than the cluster's Docker volume: with type hostPath, or with no type and a host path. With type volume, HostPath is ignored.

type Defaults

type Defaults struct {
	Image       string   `json:"image,omitempty"`
	CPUs        int      `json:"cpus,omitempty"`
	Memory      string   `json:"memory,omitempty"`
	TmpSize     string   `json:"tmpSize,omitempty"`
	CapAdd      []string `json:"capAdd,omitempty"`
	CapDrop     []string `json:"capDrop,omitempty"`
	Devices     []string `json:"devices,omitempty"`
	SecurityOpt []string `json:"securityOpt,omitempty"`
}

Defaults holds default settings applied to all nodes unless overridden.

type Node

type Node struct {
	Role             Role     `json:"role"`
	Count            int      `json:"count,omitempty"`
	Image            string   `json:"image,omitempty"`
	CPUs             int      `json:"cpus,omitempty"`
	Memory           string   `json:"memory,omitempty"`
	TmpSize          string   `json:"tmpSize,omitempty"`
	Managed          *bool    `json:"managed,omitempty"`
	BackupController bool     `json:"backupController,omitempty"`
	CapAdd           []string `json:"capAdd,omitempty"`
	CapDrop          []string `json:"capDrop,omitempty"`
	Devices          []string `json:"devices,omitempty"`
	SecurityOpt      []string `json:"securityOpt,omitempty"`
}

Node represents a single node or node group in the cluster configuration.

func (*Node) UnmarshalJSON

func (n *Node) UnmarshalJSON(data []byte) error

UnmarshalJSON supports three YAML forms:

  • bare string: "controller"
  • shorthand map: "worker: 3" (role: count)
  • full object: "role: worker\n count: 3\n cpus: 4"

type Role added in v0.7.0

type Role string

Role identifies the function of a node within a cluster.

const (
	RoleController Role = "controller"
	RoleSubmitter  Role = "submitter"
	RoleWorker     Role = "worker"
)

Valid node roles.

type Section added in v0.7.0

type Section struct {
	Content   string            // string form
	Fragments map[string]string // map form
}

Section represents a Slurm config file section that can be either:

  • a string (content appended directly to the config file)
  • a map of fragment name → content (creates a .conf.d/ directory)

func (Section) FragmentNames added in v0.7.0

func (s Section) FragmentNames() []string

FragmentNames returns the sorted keys from Fragments.

func (Section) IsEmpty added in v0.7.0

func (s Section) IsEmpty() bool

IsEmpty returns true if the section has no content and no fragments.

func (Section) IsMap added in v0.7.0

func (s Section) IsMap() bool

IsMap returns true if the section uses the map/fragments form.

func (Section) SetsParameter added in v0.10.0

func (s Section) SetsParameter(key string) bool

SetsParameter reports whether any line of the section (string form or any fragment) assigns the given slurm.conf-style parameter. Keys are matched case-insensitively, as Slurm does; comments are ignored.

func (*Section) UnmarshalJSON added in v0.7.0

func (s *Section) UnmarshalJSON(data []byte) error

UnmarshalJSON supports two YAML/JSON forms:

  • string: "content" → Section{Content: "content"}
  • map: {"key": "content"} → Section{Fragments: {"key": "content"}}

type Slurm added in v0.7.0

type Slurm struct {
	Main      Section `json:"main,omitempty"`
	Cgroup    Section `json:"cgroup,omitempty"`
	Gres      Section `json:"gres,omitempty"`
	Topology  Section `json:"topology,omitempty"`
	Plugstack Section `json:"plugstack,omitempty"`
}

Slurm configures custom Slurm configuration files. Each field maps to a Slurm config file: main → slurm.conf, cgroup → cgroup.conf, gres → gres.conf, etc.

type Storage

type Storage struct {
	DataStorage DataStorage `json:"dataStorage,omitempty"`
}

Storage configures cluster storage options.

type StorageType added in v0.7.0

type StorageType string

StorageType identifies the backing mechanism for data storage.

const (
	StorageVolume   StorageType = "volume"
	StorageHostPath StorageType = "hostPath"
)

Storage type values.

Jump to

Keyboard shortcuts

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