slurm
Experimental. For evaluation. Interfaces, configuration, and behavior may change incompatibly.
Synchronizes Slurm cluster state and supports node, reservation and topology operations.
Prerequisites
- Configured history and command modules.
- Slurm control host with
scontrolJSON support and management permissions.
Setup
- Enable Slurm:
- Register the execution host in noderegistry with the matching cluster ID and tag.
- See configuration and inventory examples.
This module must be enabled in your Remediation Orchestrator config before it is available to scripts.
This module provides functionality for interacting with slurm.
Members
- add_node_to_reservation
- add_tag_to_drain_reason
- bulk_drain
- bulk_set_slurm_state
- check_availability
- drain_node
- get_available_datacenter_node
- get_available_node
- get_breakfix_policies
- get_cluster_id
- get_domain_name
- get_drained_nodes
- get_node_by_key
- get_nodes
- get_rack_name
- get_scontrol_node
- on_drain_node
- on_reserve_node
- parse_drain_reason
- remove_all_and_add_new_reservation
- remove_all_and_add_new_reservation_batch
- remove_all_reservations
- remove_node_from_reservation
- set_slurm_state
- wait_for_node_has_active_reservations
- wait_for_node_state
- wait_for_slurm_update
add_node_to_reservation
slurm.add_node_to_reservation(cluster_id?, node_id, reservation_name, v2?, wait_for_sync?)Add a node to a reservation.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.reservation_namestringThe name of the reservation to move the node to.v2?optionalboolWhether to use the new v2 reservation change method.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.add_tag_to_drain_reason
slurm.add_tag_to_drain_reason(cluster_id?, node_id, tag, message, v2?, wait_for_sync?)Add a tag to the drain reason of a node.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.tagstringThe tag to add to the drain reason.messagestringThe message to add to the drain reason.v2?optionalboolWhether to use the new v2 reservation change method.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.bulk_drain
slurm.bulk_drain(node_ids, reason, wait_for_sync?)Drain a batch of nodes in a single scontrol call. The node list is compressed to Slurm’s hostlist range syntax before being passed to scontrol (e.g. [‘nvl72D001-T01’, …, ‘nvl72D001-T72’] becomes ‘nvl72D001-T[01-72]’). Atomic at the slurmctld layer. When wait_for_sync is true, the call blocks until every node has reached the DRAIN or DOWN state. Example: slurm.bulk_drain(domains.get_nodes(hostname), reason).
node_idslist[string]List of node IDs to drain. Empty list is a no-op.reasonstringThe reason to drain the nodes.wait_for_sync?optionalboolIf true, block until every node has reached the DRAIN or DOWN state.bulk_set_slurm_state
slurm.bulk_set_slurm_state(node_ids, state, wait_for_sync?)Set the same Slurm state on a batch of nodes in a single scontrol call. The node list is compressed to Slurm’s hostlist range syntax before being passed to scontrol (e.g. [‘nvl72D001-T01’, …, ‘nvl72D001-T72’] becomes ‘nvl72D001-T[01-72]’). scontrol applies the list element by element, so a rejected node does not stop the others and nothing is rolled back; a failure means one or more nodes were rejected, not that the whole cohort was left unchanged. Example: slurm.bulk_set_slurm_state(node_ids, “RESUME”).
node_idslist[string]List of node IDs to update. Empty list is a no-op.statestringThe state to set the nodes to.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.resultslurm.BulkSetSlurmStateResultBulk state update result with .status, .summary, .results, .workflow_run_id, and .timestamp.check_availability
slurm.check_availability(cluster_id?, max_retries?, base_retry_delay?, max_retry_delay?)Check if Slurm is available by running scontrol ping on a management node. This call respects the Slurm rate limiter and includes retry logic for transient errors.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.max_retries?optionalintMaximum number of retry attempts for transient errors. Default is 3.base_retry_delay?optionalstringBase delay between retries as a duration string (e.g., ’10s’, ‘1m’). Default is ’10s’. See https://pkg.go.dev/time#ParseDuration for full specification.max_retry_delay?optionalstringMaximum delay between retries as a duration string (e.g., ‘1m’, ‘5m’). Default is ‘1m’. See https://pkg.go.dev/time#ParseDuration for full specification.resultcommand.ExecuteCommandResultThe command execution result with exit_code, stdout, and stderr fields.drain_node
slurm.drain_node(cluster_id?, node_id, reason, v2?, wait_for_sync?)Drain a node.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.reasonstringThe reason to drain the node.v2?optionalboolWhether to use the new v2 reservation change method.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.get_available_datacenter_node
slurm.get_available_datacenter_node(cluster_id?, wait_for_sync?)Get a random available datacenter node from the deployment’s configured Slurm cluster.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the available datacenter node.nodenoderegistry.DatacenterNodeThe available datacenter node.get_available_node
slurm.get_available_node(cluster_id?, wait_for_sync?)Get a random available node (ALLOCATED or IDLE) from the deployment’s configured Slurm cluster.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the available node.nodeslurm.NodeThe available node.get_breakfix_policies
slurm.get_breakfix_policies()Get an immutable snapshot of the breakfix policies.
policiesslurm.BreakfixPoliciesConfigThe configured breakfix policy snapshot.get_cluster_id
slurm.get_cluster_id()Get the cluster ID from the Slurm module configuration
cluster_idstringThe configured cluster ID.get_domain_name
slurm.get_domain_name(hostname)Get the domain name for a given hostname using the configured rack naming pattern.
hostnamestringThe hostname to extract the domain name from.namestringThe domain name (e.g., ‘nvl72D008’).get_drained_nodes
slurm.get_drained_nodes(wait_for_sync?)Get drained node objects.
wait_for_sync?optionalboolWhether to wait for slurm updates before getting drained nodes.nodeslist[slurm.Node]List of drained node objects.get_node_by_key
slurm.get_node_by_key(cluster_id?, node_id, wait_for_sync?)Get a node by its node ID.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the node.nodeslurm.NodeThe node object.get_nodes
slurm.get_nodes(node_id_filter?, state_filter?, reason_filter?, partition_filter?, reservation_filter?, exact_node_ids_filter?, exact_states_filter?, exact_reasons_filter?, exact_partitions_filter?, exact_reservations_filter?, wait_for_sync?, updated_after_filter?, updated_before_filter?, last_busy_after_filter?, last_busy_before_filter?, reason_changed_after_filter?, reason_changed_before_filter?)Get an iterator over node objects.
node_id_filter?optionalstringFilter by node ID. Supports SLURM node list syntax.state_filter?optionalstringFilter by node state.reason_filter?optionalstringFilter by node reason.partition_filter?optionalstringFilter by partition.reservation_filter?optionalstringFilter by reservation.exact_node_ids_filter?optionallist[string]Filter by exact list of node IDs.exact_states_filter?optionallist[string]Filter by exact list of node states.exact_reasons_filter?optionallist[string]Filter by exact list of node reasons.exact_partitions_filter?optionallist[string]Filter by exact list of partitions.exact_reservations_filter?optionallist[string]Filter by exact list of reservations.wait_for_sync?optionalboolWhether to wait for slurm updates before getting nodes.updated_after_filter?optionaltimeOnly return nodes updated at or after this time.updated_before_filter?optionaltimeOnly return nodes updated before this time.last_busy_after_filter?optionaltimeOnly return nodes last busy at or after this time.last_busy_before_filter?optionaltimeOnly return nodes last busy before this time.reason_changed_after_filter?optionaltimeOnly return nodes whose reason changed at or after this time.reason_changed_before_filter?optionaltimeOnly return nodes whose reason changed before this time.nodesiterator[slurm.Node]Iterator over node objects.get_rack_name
slurm.get_rack_name(hostname)Get the rack name for a given hostname using the configured rack naming pattern.
hostnamestringThe hostname to extract the rack name from.namestringThe rack name.get_scontrol_node
slurm.get_scontrol_node(cluster_id?, wait_for_sync?)Get a datacenter node that has scontrol available for executing slurm commands.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the scontrol node.nodenoderegistry.DatacenterNodeThe scontrol-capable datacenter node.on_drain_node
slurm.on_drain_node(callback_name, workflow, drain_cooldown_duration, dry_run?, exclude_node_fn?, breakfix_exclude_node_fn?)Register a callback workflow to be launched when a node is drained.
callback_namestringThe name of the callback to register.workflowworkflows.WorkflowThe workflow to launch when a node is drained.drain_cooldown_durationstringThe duration to wait before draining the node.dry_run?optionalboolWhether to run the workflow in dry-run mode.exclude_node_fn?optionalfunctionA function to exclude a node from the callback.breakfix_exclude_node_fn?optionalfunctionA function that receives the node and configured breakfix policies and returns whether to exclude the node.on_reserve_node
slurm.on_reserve_node(callback_name, workflow, reservation_pattern, workflow_id_fn?, error_handler_fn?, exclude_node_fn?)Register a callback workflow to be launched when a node enters a named reservation.
callback_namestringThe name of the callback to register.workflowworkflows.WorkflowThe workflow to launch when a node enters the reservation.reservation_patternstringA regex pattern (or exact name) to match reservation names that trigger the callback.workflow_id_fn?optionalfunctionOptional function to compute the workflow ID. Called with (node, reservation_name) and must return a string.error_handler_fn?optionalfunctionOptional function called with the error string when a workflow execution fails.exclude_node_fn?optionalfunctionA function to exclude a node from the callback.parse_drain_reason
slurm.parse_drain_reason(reason)Parse a drain reason string and extract all tags in the format [TAG]. Returns a structured object with tags and cleaned reason.
reasonstringThe drain reason string to parse.parsed_reasonslurm.ParsedDrainReasonA ParsedDrainReason object containing tags and cleaned reason.remove_all_and_add_new_reservation
slurm.remove_all_and_add_new_reservation(cluster_id?, node_id, reservation_name, v2?, safe_reservations_to_remove?, wait_for_sync?)Remove a node from all current reservations, and add it to the specified reservation.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.reservation_namestringThe name of the reservation to move the node to.v2?optionalboolWhether to use the new v2 reservation change method.safe_reservations_to_remove?optionallist[string]Optional list of reservations that are safe to remove the node from. If empty, all reservations, that the node is attached to, are considered safe.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.remove_all_and_add_new_reservation_batch
slurm.remove_all_and_add_new_reservation_batch(node_ids, reservation_name, safe_reservations_to_remove?, wait_for_sync?)Remove current reservations from multiple nodes and add them to a reservation in batched Slurm updates.
node_idslist[string]List of node IDs to move. Empty list is a no-op.reservation_namestringThe name of the reservation to move the nodes to.safe_reservations_to_remove?optionallist[string]Optional list of reservations that are safe to remove from the nodes. If empty, all reservations attached to the nodes are considered safe.wait_for_sync?optionalboolWhether to wait for slurm updates before reading current node reservations.remove_all_reservations
slurm.remove_all_reservations(cluster_id?, node_id, v2?, safe_reservations_to_remove?, wait_for_sync?)Remove all reservations from a node.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.v2?optionalboolWhether to use the new v2 reservation change method.safe_reservations_to_remove?optionallist[string]Optional list of reservations that are safe to remove the node from. If empty, all reservations, that the node is attached to, are considered safe.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.remove_node_from_reservation
slurm.remove_node_from_reservation(cluster_id?, node_id, reservation_name, wait_for_sync?)Remove a node from a reservation.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.reservation_namestringThe name of the reservation to remove the node from.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.set_slurm_state
slurm.set_slurm_state(cluster_id?, node_id, state, v2?, wait_for_sync?)Set the state of a node.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.statestringThe state to set the node to.v2?optionalboolWhether to use the new v2 reservation change method.wait_for_sync?optionalboolWhether to wait for slurm updates before getting the datacenter node.wait_for_node_has_active_reservations
slurm.wait_for_node_has_active_reservations(cluster_id?, node_id, desired_reservations, undesired_reservations)Wait for a node to have at least one of the desired reservations and none of the undesired reservations.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.desired_reservationslist[string]List of desired reservations of the node.undesired_reservationslist[string]List of undesired reservations of the node.wait_for_node_state
slurm.wait_for_node_state(cluster_id?, node_id, desired_states, undesired_states, timeout?, retry_timeout_fn?)Wait for a node to reach a desired state.
cluster_id?optionalanyDeprecated; ignored. The deployment cluster ID is resolved internally.node_idstringThe node ID of the node.desired_stateslist[string]List of desired states of the node.undesired_stateslist[string]List of undesired states of the node.timeout?optionalstringOptional Go duration string (e.g., ’30s’, ‘1m’, ‘1h’).retry_timeout_fn?optionalfunctionOptional function to call on timeout. It may accept the node ID and must return bool.wait_for_slurm_update
slurm.wait_for_slurm_update(num_updates)Wait for a specified number of Slurm database updates.
num_updatesintThe number of Slurm database updates to wait for.