TT Lab
Blog Get started
Learn Learning paths Courses

HPC and Slurm

Writing slurm.conf

Continue in TT Lab

Goal

You write a slurm.conf that meets the requirements from scratch, and create a consistency validation script yourself.

Why it matters

Slurm configuration errors appear late and in unrelated places. A node drops into INVAL or DOWN, and the log has one line with the cause, but if you do not look at it you wander for days. The two most common are CPUs differing from sockets × cores × threads and a partition referencing a node that is not defined. Both are mistakes that occur when a person calculates by hand, and both can be caught in advance by a script.

The actual slurmd is not run. The configuration you write and the validation script are graded.

Requirements of this lab

Steps

  1. Create /etc/slurm and /root/slurm, and prepare the daemon account slurm along with /var/spool/slurmctld, /var/spool/slurmd, and /var/log/slurm, which only that account can write to. Keep /etc/slurm owned by root so the slurm account cannot modify it.
  2. Create /etc/slurm/slurm.conf and put in the following keys. ClusterName=labhub-hpc, SlurmctldHost=ctl01, SlurmUser=slurm, StateSaveLocation=/var/spool/slurmctld, SlurmdSpoolDir=/var/spool/slurmd, AuthType=auth/munge
  3. Add the scheduling-related keys. SchedulerType=sched/backfill, SelectType=select/cons_tres, SelectTypeParameters=CR_Core_Memory, ProctrackType=proctrack/cgroup, TaskPlugin=task/cgroup,task/affinity
  4. Define the 3 nodes. Each line must start with NodeName= and include Sockets, CoresPerSocket, ThreadsPerCore, CPUs, RealMemory, and State. The CPUs value must match sockets × cores × threads.
  5. Define the 2 partitions. batch has Default=YES and MaxTime=24:00:00, and short has MaxTime=01:00:00. In both partitions, the nodes written in Nodes= must be the ones defined in step 4.
  6. Add the log and accounting keys. SlurmctldLogFile=/var/log/slurm/slurmctld.log, SlurmdLogFile=/var/log/slurm/slurmd.log, JobAcctGatherType=jobacct_gather/cgroup, ReturnToService=2
  7. Create the munge user and group, generate /etc/munge/munge.key as 1024 bytes of random data, and set the permission 0400 and the owner munge:munge.
  8. Write /root/slurm/validate.sh. It takes the slurm.conf path as its first argument, checks the following two rules, and must exit with code 0 if there is no violation and with a nonzero value if there is.
    • Rule 1: On every NodeName= line, CPUs must equal Sockets × CoresPerSocket × ThreadsPerCore
    • Rule 2: The nodes that appear in Nodes= on every PartitionName= line must be defined with NodeName= (expand and check the range notation gpu-node[01-03]) The grader runs it against both your /etc/slurm/slurm.conf (which must pass) and /opt/fixtures/slurm/broken/slurm.conf (which must fail).

Notes

Separate the owners of the configuration and state directories

Create /etc/slurm and the working directory /root/slurm, create the daemon account slurm (a system account), then prepare the three places Slurm writes to: /var/spool/slurmctld, /var/spool/slurmd, and /var/log/slurm. The three places must actually be writable by the slurm account and must not be writable by any other account. Conversely, keep /etc/slurm owned by root so the slurm account cannot modify it.

Direction: express the split, where the administrator writes the configuration and the daemon writes state and logs, through directory ownership. Tools: the command that creates a system account, the command that changes an owner, and permission bits. Concretely: do not judge "is it writable" by reading the permission bits; test it directly as that account (test -w with runuser). Opening write access to everyone is not the answer.

Write the basic keys

Create /etc/slurm/slurm.conf and put in the following keys. ClusterName=labhub-hpc, SlurmctldHost=ctl01, SlurmUser=slurm, StateSaveLocation=/var/spool/slurmctld, SlurmdSpoolDir=/var/spool/slurmd, AuthType=auth/munge

The basics are the cluster name, the controller host, the run account, the state save path, and the authentication method.

Scheduler and resource selection

Add the scheduling-related keys. SchedulerType=sched/backfill, SelectType=select/cons_tres, SelectTypeParameters=CR_Core_Memory, ProctrackType=proctrack/cgroup, TaskPlugin=task/cgroup,task/affinity

On a GPU cluster you need a selection plugin that splits resources per core. Memory must also be included among the consumable resources.

Define the nodes

Define the 3 nodes. Each line must start with NodeName= and include Sockets, CoresPerSocket, ThreadsPerCore, CPUs, RealMemory, and State. The CPUs value must match sockets × cores × threads.

CPUs must match sockets × cores × threads. Check the calculation twice.

Define the partitions

Define the 2 partitions. batch has Default=YES and MaxTime=24:00:00, and short has MaxTime=01:00:00. In both partitions, the nodes written in Nodes= must be the ones defined in step 4.

Every node written in Nodes must be defined. Specify only one default partition.

Logs and accounting

Add the log and accounting keys. SlurmctldLogFile=/var/log/slurm/slurmctld.log, SlurmdLogFile=/var/log/slurm/slurmd.log, JobAcctGatherType=jobacct_gather/cgroup, ReturnToService=2

You need log paths for the controller and for the nodes. Also specify the resource-gathering plugin.

Prepare the munge key

Create the munge user and group, generate /etc/munge/munge.key as 1024 bytes of random data, and set the permission 0400 and the owner munge:munge.

munged comes up only if the key file's permission and owner are exact. There is also a prescribed size.

Consistency validation script

Write /root/slurm/validate.sh. It takes the slurm.conf path as its first argument, checks the following two rules, and must exit with code 0 if there is no violation and with a nonzero value if there is.

The grader runs it against both the valid configuration and the broken configuration in the fixture. Distinguish them by the exit code.