Repository navigation
Slurm workload attestor - #7160
Conversation
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a new built-in SPIRE Agent WorkloadAttestor plugin for Slurm (cgroup v2), plus an end-to-end integration suite that spins up a single-node Slurm environment and validates X.509-SVID issuance for a Slurm batch job.
Changes:
- Added
slurmworkload attestor plugin (POSIX implementation + Windows stub) and wired it into the agent catalog. - Added unit tests for Slurm cgroup parsing and a new
slurm-x509integration suite that exercises real Slurm job attestation via cgroup v2. - Updated CI runner OS for the main integration job matrix to Ubuntu 24.04 to support host systemd/cgroup v2 behavior needed by the Slurm suite.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/integration/suites/slurm-x509/teardown | Cleans up suite resources and dumps diagnostics on failure |
| test/integration/suites/slurm-x509/README.md | Documents suite topology and host/containers setup rationale |
| test/integration/suites/slurm-x509/docker-compose.yaml | Runs server/agent containers with host PID+cgroup sharing for attestation |
| test/integration/suites/slurm-x509/conf/slurm/slurm.conf | Minimal Slurm config enabling cgroup-based proctrack/task plugins |
| test/integration/suites/slurm-x509/conf/slurm/cgroup.conf | Configures Slurm to use cgroup/v2 plugin without constraints |
| test/integration/suites/slurm-x509/conf/server/server.conf | Suite-local SPIRE server config |
| test/integration/suites/slurm-x509/conf/job/fetch-svid.sh | Slurm job payload that repeatedly fetches an X.509-SVID until issued |
| test/integration/suites/slurm-x509/conf/agent/agent.conf | Suite-local SPIRE agent config enabling the slurm attestor |
| test/integration/suites/slurm-x509/06-verify-fetch | Verifies Slurm job obtained expected SPIFFE ID and output artifacts |
| test/integration/suites/slurm-x509/05-create-entry | Creates a registration entry using slurm selectors and waits for sync |
| test/integration/suites/slurm-x509/04-submit-job | Submits the Slurm job and waits until it is running |
| test/integration/suites/slurm-x509/03-start-agent | Starts agent container and verifies successful node attestation |
| test/integration/suites/slurm-x509/02-bootstrap-agent | Fetches bundle to bootstrap the agent |
| test/integration/suites/slurm-x509/01-start-server | Starts server container |
| test/integration/suites/slurm-x509/00-setup | Installs/configures Slurm+munge on host and prepares shared dirs/binaries |
| pkg/agent/plugin/workloadattestor/slurm/slurm.go | Declares plugin name and BuiltIn registration entrypoint |
| pkg/agent/plugin/workloadattestor/slurm/slurm_windows.go | Windows stub returning Unimplemented for Slurm attestation |
| pkg/agent/plugin/workloadattestor/slurm/slurm_posix.go | POSIX Slurm cgroup parsing and selector emission |
| pkg/agent/plugin/workloadattestor/slurm/slurm_posix_test.go | Unit tests for Slurm cgroup parsing and selector output |
| pkg/agent/catalog/workloadattestor.go | Registers the new built-in slurm workload attestor |
| doc/plugin_agent_workloadattestor_slurm.md | Adds plugin documentation and selector reference |
| .github/workflows/release_build.yaml | Updates integration job runner OS to Ubuntu 24.04/24.04-arm |
| .github/workflows/pr_build.yaml | Updates integration job runner OS to Ubuntu 24.04/24.04-arm |
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
| @@ -0,0 +1,43 @@ | |||
| #!/bin/bash | |||
| #SBATCH --job-name=spire-fetch | |||
There was a problem hiding this comment.
Is it not possible to get this job name as a selector in some way? I imagine this would be a bit more useful than the IDs.
There was a problem hiding this comment.
https://slurm.schedmd.com/rest_api.html#slurmV0045GetJob seems to have some more details about the job, the name, some group name, and maybe others.
There was a problem hiding this comment.
the job name is a slurm user specifiable field for the user to help keep track of their own jobs. It will be insecure when used alone as a selector. So not super useful to spire setups I think.
I was trying to keep things simple. slurm-rest is not a commonly deployed component, and there is no standard way for a node to auth to it.
The easiest extension point would be to add a slurm prolog script on the compute nodes that pushes any of the metadata that slurm pushes to the hook:
Prolog gives you a decent set: SLURM_JOB_ID, SLURM_JOB_UID/GID/USER, SLURM_JOB_NODELIST, SLURM_JOB_PARTITION, SLURM_JOB_QOS, SLURM_JOB_ACCOUNT, SLURM_JOB_START_TIME, SLURM_JOB_WORK_DIR, SLURM_JOB_STDOUT/STDERR, SLURM_JOB_CONSTRAINTS, SLURM_JOB_GPUS, SLURM_JOB_SLUID, SLURMD_NODENAME, SLURM_CLUSTER_NAME
then get that data to the spire-agent plugin somehow. like dump it to json files. job name was left out I think as its a user field, so not for hooks.
Of those though, I think the only really useful ones are SLURM_CLUSTER_NAME and SLURM_JOB_ACCOUNT. USER info is attestable via the unix attestor already.
I'm not convinced any of those are worth making workload selectors for though. Just my 2c.
So, none of this helps with eliminating the need of of plumbing that makes the registration entries dynamically per job in spire. The most useful thing would be if you could do it per slurm account, but HPC systems often run into lots of scaling issues due to their size. Blanket adding x509 entries on nodes where the jobs are not registered to will make the scaling issue much worse. So an account selector, being the most useful other selector, doesnt really help much. Its super useful as a template item for the spiffe_id though.
So my suggestion would be, lets merge the functionality as is. Its simple and doesn't require extra scripts or advanced configuration of slurm on the compute nodes to get it to work. As we get more users of it, maybe some will think the extra functionality is worth the effort, and we can enhance it then. Or, after I try and use it for a while, maybe I'll change my mind and need it too. But, this current level of functionality feels like a good starting point to me.
There was a problem hiding this comment.
Thanks for the information. So how would the SPIFFE IDs for these entries look like? Something like spiffe://<trust domain>/sluid/<sluid>job/<id>? Also, how would the nodes where the job runs be identified?
There was a problem hiding this comment.
I'm planning on using spiffe://<trust domain>/<clustername>/<slurm account>
As previously mentioned, a spire-controller-manager like process that runs on the control plane node and collects job information from the slurm controller and pushes in the registration entries to spire. Hence the SSC request for another repo for that code.
As a taste though, this generates the list of running jobs and the node sets the job is running on:
squeue --json | jq -r '.jobs[] | select(IN(.job_state[]; "RUNNING")) | .job_id as $id | .account as $account | .job_resources | select(IN(.select_type[]; "CORE")) | "($account) ($id) (.nodes.list)"'
Example output:
project1 819721 t28
project1 819752 t[24,27,35-36]
project2 819846 t[53,101],ta18
project3 819912 t77
project1 820052 t86
amartinezfayo
left a comment
There was a problem hiding this comment.
Thank you @kfox1111 for this contribution!
| @@ -0,0 +1,40 @@ | |||
| # Agent plugin: WorkloadAttestor "slurm" | |||
There was a problem hiding this comment.
I would be good to also have this new plugin in the plugin table in the SPIRE Agent documentation and the full agent reference config.
| | `slurm:sluid` | Slurm SLUID of the job; the default job identifier (e.g. `slurm:sluid:s5K1KKYAYG5D00`). | | ||
| | `slurm:step` | Job step: a number or `batch`/`extern`/`interactive` (e.g. `slurm:step:batch`). | | ||
|
|
||
| Exactly one of `slurm:job_id` or `slurm:sluid` is produced for a given workload, depending |
There was a problem hiding this comment.
I think this framing may only hold for Slurm 26.05 and later. Before 26.05 the cgroup/v2 layout always used job_ directories (that is what the suite's Slurm 23.11 produces), and SLUID naming + the CgroupJobIdPaths option were introduced in 26.05 (https://slurm.schedmd.com/cgroup.conf.html). I'm not sure what's the best way to handle this, would it make sense to qualify this by version so operators on older Slurm don't go looking for a knob that doesn't exist?
There was a problem hiding this comment.
I took a stab at it.
There was a problem hiding this comment.
Thanks for updating this. I think the job_id row now conflicts with itself though. CgroupJobIdPaths only exists on 26.05 and later, where setting it to yes emits numeric job ids, while before 26.05 numeric ids are emitted unconditionally, so the row shouldn't say the selector only applies to versions older than 26.05. Maybe something like "Numeric Slurm job id. Emitted on Slurm older than 26.05, or on 26.05 and later when CgroupJobIdPaths=yes". There's also a small typo in the sluid row (verison).
There was a problem hiding this comment.
oh. yeah.
I just took another stab at it. How does this look?
|
|
||
| ## Platform support | ||
|
|
||
| This plugin is only supported on Unix systems and requires that Slurm is configured to use |
There was a problem hiding this comment.
It could be worth documenting the deployment requirement here as well. When the agent runs in a container it needs to share the host PID and cgroup namespaces (as the suite's compose file does), since (I think?) otherwise /proc//cgroup won't show the host-rooted /system.slice path and Slurm workloads would attest with no selectors.
| sudo rm -rf /tmp/slurm-spire-sockets /tmp/slurm-spire-jobs | ||
| sudo install -d -m 0777 /tmp/slurm-spire-sockets /tmp/slurm-spire-jobs | ||
|
|
||
| # --- Install and configure a single-node Slurm cluster on the host --------- |
There was a problem hiding this comment.
Maybe we should guard this step against a machine that already runs Slurm?
It overwrites /etc/slurm/slurm.conf, installs a binary into /usr/local/bin, and restarts munge/slurmctld/slurmd, and the teardown stops those daemons and cancels all jobs, which could be destructive on a developer host with a real Slurm install. Failing early when slurmd or munge is already active (or unless running in CI) would keep that from happening by accident, what do you think?
There was a problem hiding this comment.
Hmm, I was assuming no one would run the integration tests on their own boxes... Maybe this was a wrong assumption?
Should we do something like look for the GITHUB ACTIONS env vars and just deny the test if they are not in the environment?
There was a problem hiding this comment.
Checking for GITHUB_ACTIONS and refusing to run otherwise sounds reasonable to me. I'll just note that this would diverge from how the other suites handle host dependencies, which is to run everything in containers. Since the regex requires the slurmstepd scope to live under the real host /system.slice, I think containerizing Slurm isn't really an option here, so gating on the CI environment seems like a fair trade-off. Maybe we could also accept an explicit opt-in (for example SLURM_SUITE_ALLOW_HOST_CHANGES=1) so the suite can still be run deliberately outside CI for debugging, say in a disposable VM.
It would be good to update the test suite README with these details.
There was a problem hiding this comment.
Hmm, I was assuming no one would run the integration tests on their own boxes... Maybe this was a wrong assumption?
Our posture has been that the integration tests can be run on dev machines without needing CI infrastructure. make integration runs all the suites by default and supports running individual ones with SUITES.
There was a problem hiding this comment.
ok. Maybe I tweak the job to skip the job but pass then?
There was a problem hiding this comment.
Ok. I took a stab at fixing this too.
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
| } | ||
| } | ||
|
|
||
| # WorkloadAttestor "slurm": A workload attestor which allows selectors based |
There was a problem hiding this comment.
nit: the WorkloadAttestor entries here are in alphabetical order, so this one would go between k8s and systemd. The other Unix-only attestors also include a "Supported on Unix only." line in their description, which would be worth adding here too.
| | `slurm:sluid` | Slurm SLUID of the job; the default job identifier (e.g. `slurm:sluid:s5K1KKYAYG5D00`). | | ||
| | `slurm:step` | Job step: a number or `batch`/`extern`/`interactive` (e.g. `slurm:step:batch`). | | ||
|
|
||
| Exactly one of `slurm:job_id` or `slurm:sluid` is produced for a given workload, depending |
There was a problem hiding this comment.
Thanks for updating this. I think the job_id row now conflicts with itself though. CgroupJobIdPaths only exists on 26.05 and later, where setting it to yes emits numeric job ids, while before 26.05 numeric ids are emitted unconditionally, so the row shouldn't say the selector only applies to versions older than 26.05. Maybe something like "Numeric Slurm job id. Emitted on Slurm older than 26.05, or on 26.05 and later when CgroupJobIdPaths=yes". There's also a small typo in the sluid row (verison).
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Signed-off-by: Kevin Fox <[email protected]>
Pull Request check list
Affected functionality
NA
Description of change
Adds a new slurm workload attestor
Which issue this PR fixes
#7153