Skip to content

Use case: workshop users

The scenario:

I am hosting a hackathon and want to add non-admin users. Each user should only be allowed to run a single Slurm job (max 8 GPUs) at a time.

This takes three steps: create the users, create a limiting QoS, and make sure Slurm actually enforces it.

1. Create the users

Use slinky-user-add on the login node (ssh -p 2222 ubuntu@<cluster-ip>). One command per user provisions the Kanidm identity, POSIX account, Slurm association and SSH access:

sudo slinky-user-add alice --display-name "Alice Example" \
  --ssh-key "ssh-ed25519 AAAA... alice@laptop" --test

--test runs a smoke test that confirms the user can start a Slurm step.

Users then connect with:

ssh alice@<cluster-ip>

Tip

The first SSH attempt as a freshly created user can fail with Permission denied while the nodes' kanidm caches warm up. Retry after a few seconds.

2. Limit each user to one job

Create the QoS once, then assign it to every workshop user (run as admin on the login node; -i commits immediately instead of prompting):

sudo sacctmgr -i add qos limited_qos MaxTRESPerUser=gres/gpu=8 MaxJobsPerUser=1
sudo sacctmgr -i modify user alice set DefaultQOS=limited_qos QOS=limited_qos

Note

If the QoS already exists, add qos prints Nothing new added. and exits 1, and it never changes limits on an existing QoS. Adjust an existing one with modify:

sudo sacctmgr -i modify qos limited_qos set MaxTRESPerUser=gres/gpu=8 MaxJobsPerUser=1

3. Enable enforcement

Slinky clusters ship with AccountingStorageEnforce unset, so QoS limits are not enforced until you add this via the controller's extraConf (see Changing the Slurm configuration):

AccountingStorageEnforce=associations,limits,qos

Note

With associations enforced, every submitting identity needs a Slurm association. Admin submissions through the login-node wrappers run as root, which keeps working because the root association (account root) is created automatically with the cluster. After enabling enforcement, verify the admin path with sudo srun true.

4. Verify

First confirm the controller loaded the limits:

scontrol show assoc_mgr qos=limited_qos   # shows MaxJobsPU=1 and usage counters

Then, as a workshop user (logged in to the login pod), confirm the identity and the limit:

srun id                      # shows the user's own uid, not root
sbatch --wrap "sleep 300" && sbatch --wrap "sleep 300"
squeue --me -O jobid,state,reason   # second job pends with QOSMaxJobsPerUserLimit

Tip

By default an over-limit job pends until capacity frees up. To reject it at submit time instead (clearer for workshop users), set:

sudo sacctmgr -i modify qos limited_qos set Flags=DenyOnLimit

Removing users afterwards

sudo slinky-user-remove alice --yes --archive-home