slurm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 0 modules, 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 slurm reads and changes the state of a Slurm cluster through its command line clients, which run on a host that has them.

Output is asked for in the parsable form with an explicit field list and split on the separator, rather than parsed out of the aligned display form. The display form changes with the terminal width and truncates, which is how a power state ended up reported against the wrong node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StateGroups

func StateGroups() map[string][]string

StateGroups maps the short names the commands accept to the Slurm states they stand for.

func States

func States(arg string) []string

States turns a state group name, or a comma separated list of states, into the states to ask Slurm for. An empty argument asks for every state.

Types

type Accounting

type Accounting struct {
	JobID     string `json:"jobId" yaml:"jobId"`
	User      string `json:"user,omitempty" yaml:"user,omitempty"`
	Account   string `json:"account,omitempty" yaml:"account,omitempty"`
	State     string `json:"state,omitempty" yaml:"state,omitempty"`
	ExitCode  string `json:"exitCode,omitempty" yaml:"exitCode,omitempty"`
	Nodes     string `json:"nodes,omitempty" yaml:"nodes,omitempty"`
	Elapsed   string `json:"elapsed,omitempty" yaml:"elapsed,omitempty"`
	Start     string `json:"start,omitempty" yaml:"start,omitempty"`
	End       string `json:"end,omitempty" yaml:"end,omitempty"`
	Submit    string `json:"submit,omitempty" yaml:"submit,omitempty"`
	Partition string `json:"partition,omitempty" yaml:"partition,omitempty"`
}

Accounting is one finished job from the accounting database.

type AccountingFilter

type AccountingFilter struct {
	States   []string
	Users    []string
	JobIDs   []string
	Since    time.Duration
	AllUsers bool
}

AccountingFilter selects which finished jobs to list.

type Association

type Association struct {
	Account        string `json:"account" yaml:"account"`
	User           string `json:"user,omitempty" yaml:"user,omitempty"`
	DefaultAccount string `json:"defaultAccount,omitempty" yaml:"defaultAccount,omitempty"`
	Coordinators   string `json:"coordinators,omitempty" yaml:"coordinators,omitempty"`
	Organization   string `json:"organization,omitempty" yaml:"organization,omitempty"`
	Description    string `json:"description,omitempty" yaml:"description,omitempty"`
	FairShare      string `json:"fairShare,omitempty" yaml:"fairShare,omitempty"`
	MaxJobs        string `json:"maxJobs,omitempty" yaml:"maxJobs,omitempty"`
	MaxSubmit      string `json:"maxSubmit,omitempty" yaml:"maxSubmit,omitempty"`
	MaxNodes       string `json:"maxNodes,omitempty" yaml:"maxNodes,omitempty"`
	MaxCPUs        string `json:"maxCpus,omitempty" yaml:"maxCpus,omitempty"`
	MaxWall        string `json:"maxWall,omitempty" yaml:"maxWall,omitempty"`
}

Association is a user or account entry of the accounting database.

type Client

type Client struct {
	// Runner executes the client, usually over ssh.
	Runner transport.Runner
	// Target is the host the clients run on.
	Target transport.Target
	// Spec is the Slurm configuration of the cluster.
	Spec v1alpha1.SlurmSpec
	// Timeout bounds one client invocation.
	Timeout time.Duration
}

Client runs the Slurm clients on the configured host.

func (*Client) AccountLimits

func (c *Client) AccountLimits(ctx context.Context, account string) ([]Association, error)

AccountLimits lists the associations of an account with their limits.

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context, name string) ([]Association, error)

Accounts lists the accounts with their coordinators.

func (*Client) AddAccount

func (c *Client) AddAccount(ctx context.Context, name, organization, description string) error

AddAccount creates an account.

func (*Client) AddUser

func (c *Client) AddUser(ctx context.Context, user, account, defaultAccount string) error

AddUser associates a user with an account, creating the association when the user has none.

func (*Client) Drain

func (c *Client) Drain(ctx context.Context, ns *nodeset.NodeSet, reason string) error

Drain removes nodes from production with a reason.

The reason is mandatory: a drained node with no reason is a node nobody dares resume.

func (*Client) HasPosixUser

func (c *Client) HasPosixUser(ctx context.Context, user string) (bool, error)

HasPosixUser reports whether the cluster knows a user account at all.

getent is asked rather than id, because id answers from the local files as well and would claim a user exists that the directory does not know.

func (*Client) History

func (c *Client) History(ctx context.Context, f AccountingFilter) ([]Accounting, error)

History reads finished jobs from the accounting database.

func (*Client) Jobs

func (c *Client) Jobs(ctx context.Context, f JobFilter) ([]Job, error)

Jobs lists the jobs in the queue.

func (*Client) NodeSet

func (c *Client) NodeSet(ctx context.Context, states []string) (*nodeset.NodeSet, error)

NodeSet returns the nodes in the given states as a set.

func (*Client) Nodes

func (c *Client) Nodes(ctx context.Context, ns *nodeset.NodeSet, states []string) ([]Node, error)

Nodes lists the nodes, optionally limited to a set or to states.

func (*Client) Partitions

func (c *Client) Partitions(ctx context.Context, name string) ([]Partition, error)

Partitions lists the partitions.

func (*Client) Resume

func (c *Client) Resume(ctx context.Context, ns *nodeset.NodeSet) error

Resume puts nodes back into production.

func (*Client) SetCoordinators

func (c *Client) SetCoordinators(ctx context.Context, account string, users []string) error

SetCoordinators makes users coordinators of an account.

func (*Client) SetDefaultAccount

func (c *Client) SetDefaultAccount(ctx context.Context, user, account string) error

SetDefaultAccount changes the default account of a user.

func (*Client) SetFairShare

func (c *Client) SetFairShare(ctx context.Context, account, value string) error

SetFairShare sets the fair-share value of an account.

func (*Client) Shares

func (c *Client) Shares(ctx context.Context, account string) ([]Association, error)

Shares lists the fair-share situation.

func (*Client) Users

func (c *Client) Users(ctx context.Context, user string) ([]Association, error)

Users lists the user associations.

type Job

type Job struct {
	ID        string `json:"id" yaml:"id"`
	User      string `json:"user,omitempty" yaml:"user,omitempty"`
	Account   string `json:"account,omitempty" yaml:"account,omitempty"`
	Partition string `json:"partition,omitempty" yaml:"partition,omitempty"`
	State     string `json:"state,omitempty" yaml:"state,omitempty"`
	Nodes     string `json:"nodes,omitempty" yaml:"nodes,omitempty"`
	NodeCount string `json:"nodeCount,omitempty" yaml:"nodeCount,omitempty"`
	CPUs      string `json:"cpus,omitempty" yaml:"cpus,omitempty"`
	TimeLimit string `json:"timeLimit,omitempty" yaml:"timeLimit,omitempty"`
	Runtime   string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
	Priority  string `json:"priority,omitempty" yaml:"priority,omitempty"`
	Reason    string `json:"reason,omitempty" yaml:"reason,omitempty"`
	WorkDir   string `json:"workDir,omitempty" yaml:"workDir,omitempty"`
	Command   string `json:"command,omitempty" yaml:"command,omitempty"`
}

Job is one job in the queue.

type JobFilter

type JobFilter struct {
	States []string
	Users  []string
	Nodes  *nodeset.NodeSet
}

JobFilter selects which jobs to list.

type Node

type Node struct {
	Name       string `json:"name" yaml:"name"`
	State      string `json:"state" yaml:"state"`
	Partition  string `json:"partition,omitempty" yaml:"partition,omitempty"`
	CPUs       string `json:"cpus,omitempty" yaml:"cpus,omitempty"`
	Memory     string `json:"memory,omitempty" yaml:"memory,omitempty"`
	Features   string `json:"features,omitempty" yaml:"features,omitempty"`
	GRES       string `json:"gres,omitempty" yaml:"gres,omitempty"`
	Reason     string `json:"reason,omitempty" yaml:"reason,omitempty"`
	ReasonUser string `json:"reasonUser,omitempty" yaml:"reasonUser,omitempty"`
	ReasonTime string `json:"reasonTime,omitempty" yaml:"reasonTime,omitempty"`
}

Node is one node as Slurm sees it.

func (Node) BaseState

func (n Node) BaseState() string

BaseState strips the flag characters Slurm appends to a state, so that "idle*" and "idle" compare equal.

type Partition

type Partition struct {
	Name        string `json:"name" yaml:"name"`
	Available   string `json:"available,omitempty" yaml:"available,omitempty"`
	Groups      string `json:"groups,omitempty" yaml:"groups,omitempty"`
	Nodes       string `json:"nodes,omitempty" yaml:"nodes,omitempty"`
	NodeCount   string `json:"nodeCount,omitempty" yaml:"nodeCount,omitempty"`
	DefaultTime string `json:"defaultTime,omitempty" yaml:"defaultTime,omitempty"`
	MaxTime     string `json:"maxTime,omitempty" yaml:"maxTime,omitempty"`
	Memory      string `json:"memory,omitempty" yaml:"memory,omitempty"`
	CPUs        string `json:"cpus,omitempty" yaml:"cpus,omitempty"`
	CPUState    string `json:"cpuState,omitempty" yaml:"cpuState,omitempty"`
}

Partition is one Slurm partition.

Jump to

Keyboard shortcuts

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