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
- func Arg(req transport.Request, option string) string
- func Render(req transport.Request, rows ...Row) string
- func StateGroups() map[string][]string
- func States(arg string) []string
- func ValidateFairShare(value string) error
- func ValidateName(kind, value string) error
- func ValidateReason(reason string) error
- func ValidateText(kind, value string) error
- func ValidateUserName(value string) error
- type Accounting
- type AccountingFilter
- type Association
- type Client
- func (c *Client) AccountLimits(ctx context.Context, account string) ([]Association, error)
- func (c *Client) Accounts(ctx context.Context, name string) ([]Association, error)
- func (c *Client) AddAccount(ctx context.Context, name, organization, description string) error
- func (c *Client) AddUser(ctx context.Context, u UserAddition) error
- func (c *Client) CheckNodes(ctx context.Context, ns *nodeset.NodeSet) error
- func (c *Client) Cluster(ctx context.Context) (string, error)
- func (c *Client) Drain(ctx context.Context, ns *nodeset.NodeSet, reason string) error
- func (c *Client) HasPosixUser(ctx context.Context, user string) (bool, error)
- func (c *Client) History(ctx context.Context, f AccountingFilter) ([]Accounting, error)
- func (c *Client) Jobs(ctx context.Context, f JobFilter) ([]Job, error)
- func (c *Client) NodeSet(ctx context.Context, states []string) (*nodeset.NodeSet, error)
- func (c *Client) Nodes(ctx context.Context, ns *nodeset.NodeSet, states []string) ([]Node, error)
- func (c *Client) Organization(organization string) string
- func (c *Client) Partitions(ctx context.Context, name string) ([]Partition, error)
- func (c *Client) PlanUserAdd(ctx context.Context, user, account, defaultAccount string) (UserAddition, error)
- func (c *Client) Resume(ctx context.Context, ns *nodeset.NodeSet) error
- func (c *Client) SetCoordinators(ctx context.Context, account string, users []string) error
- func (c *Client) SetDefaultAccount(ctx context.Context, user, account string) error
- func (c *Client) SetFairShare(ctx context.Context, account, value string) error
- func (c *Client) Shares(ctx context.Context, account string) ([]Association, error)
- func (c *Client) Users(ctx context.Context, user string) ([]Association, error)
- type Job
- type JobFilter
- type Node
- type Partition
- type Row
- type UserAddition
Constants ¶
const MaxReasonLength = 200
MaxReasonLength is the longest drain reason accepted, in characters.
Variables ¶
This section is empty.
Functions ¶
func Arg ¶ added in v0.3.0
Arg returns the value that follows an option in a request, or the empty string when the request does not have the option.
func Render ¶ added in v0.3.0
Render prints rows the way sinfo or squeue print them for the format a request asks for, so that a test double does not have to know how the client lays its output out. A field the row does not name is empty.
func StateGroups ¶
StateGroups maps the short names the commands accept to the Slurm states they stand for.
func States ¶
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.
func ValidateFairShare ¶ added in v0.3.0
ValidateFairShare checks a fair-share value.
func ValidateName ¶ added in v0.3.0
ValidateName checks an account or user name before it is shown or sent. kind says what the name is, for the error.
func ValidateReason ¶ added in v0.3.0
ValidateReason checks a drain reason before anything is shown or sent.
The reason is mandatory: a drained node with no reason is a node nobody dares resume. It is shown in the confirmation, stored by Slurm and printed back by sinfo, so it may not hold control characters, which could rewrite what the confirmation shows, nor the separator of the parsable output.
func ValidateText ¶ added in v0.3.0
ValidateText checks a free text value, such as an account description, which may not hold control characters.
func ValidateUserName ¶ added in v0.3.0
ValidateUserName is ValidateName for a user, which also may not be a number: getent resolves a number as a user ID.
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"`
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 clients that change something, usually over ssh.
Runner transport.Runner
// Reader executes the clients that only read. It stays the real
// transport in a dry run, so that the checks made before a change see
// the cluster rather than an empty recording. It defaults to Runner.
Reader 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
// contains filtered or unexported fields
}
Client runs the Slurm clients on the configured host.
func (*Client) AccountLimits ¶
AccountLimits lists the associations of an account with their limits.
func (*Client) AddAccount ¶
AddAccount creates an account in the cluster.
func (*Client) AddUser ¶
func (c *Client) AddUser(ctx context.Context, u UserAddition) error
AddUser carries out an addition PlanUserAdd resolved.
func (*Client) CheckNodes ¶ added in v0.3.0
CheckNodes makes sure Slurm reads a node set as exactly those nodes.
scontrol update does not take its node list as plain host names: slurmctld expands ALL, in any case, to every node and a NodeSet name of slurm.conf to its members. Such a word looks like one host to clusterctl, so the gate would preview, count and check one host while Slurm changed many. sinfo reads the list the same way, so the set is refused unless sinfo returns exactly the nodes named, and a node Slurm does not know is refused before scontrol changes the ones it reached and then stops. A node that belongs to no partition is not listed by sinfo and is refused too, which errs on the safe side.
func (*Client) Cluster ¶ added in v0.3.0
Cluster returns the name slurm.conf gives the cluster.
One slurmdbd can serve several clusters, and sacctmgr applies a change that names no cluster to all of them. Every accounting change clusterctl makes therefore names the cluster its login node belongs to.
func (*Client) Drain ¶
Drain removes nodes from production with a reason.
scontrol update is not atomic: slurmctld changes the nodes it reaches and stops at the first it cannot change. When the update fails, the nodes are read back, and the error says which of them are drained with this reason.
func (*Client) HasPosixUser ¶
HasPosixUser reports whether the cluster knows a user account at all.
getent resolves the name through the name service switch of the login node, which includes its local files. It exits 2 for a name it 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) Nodes ¶
Nodes lists the nodes, optionally limited to a set or to states.
A state is matched against the state Slurm reports for the node, not only against what sinfo selects by: sinfo matches a plain state against the base state and the flags, so asking it for idle also returns drained nodes.
func (*Client) Organization ¶ added in v0.3.0
Organization returns the organisation a new account gets when none is given.
func (*Client) Partitions ¶
Partitions lists the partitions.
func (*Client) PlanUserAdd ¶ added in v0.3.0
func (c *Client) PlanUserAdd(ctx context.Context, user, account, defaultAccount string) (UserAddition, error)
PlanUserAdd resolves what adding a user to an account does: which account an omitted one stands for, whether the user exists, and which associations and default account result.
func (*Client) Resume ¶
Resume puts nodes back into production. A failed update is read back the way Drain reads it back.
func (*Client) SetCoordinators ¶
SetCoordinators makes users coordinators of an account.
func (*Client) SetDefaultAccount ¶
SetDefaultAccount changes the default account of a user in the cluster.
func (*Client) SetFairShare ¶
SetFairShare sets the fair-share value of an account in the cluster.
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 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.
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.
type Row ¶ added in v0.3.0
Row is one line of a fake sinfo or squeue answer: the value of each field, keyed by its format letter, "N" for %N.
type UserAddition ¶ added in v0.3.0
type UserAddition struct {
User string
Cluster string
// Account is the account the user is associated with.
Account string
// DefaultAccount is the default account the user ends up with. For a
// user who exists already it is empty when the default stays as it is.
DefaultAccount string
// Exists says the user has associations in the cluster already.
Exists bool
// Current is the default account of a user who exists already.
Current string
// contains filtered or unexported fields
}
UserAddition is what adding a user to an account does, resolved before it is shown.
func (UserAddition) Changes ¶ added in v0.3.0
func (u UserAddition) Changes() bool
Changes reports whether the addition changes anything.
func (UserAddition) String ¶ added in v0.3.0
func (u UserAddition) String() string
String says what the addition does, for the confirmation.