Skip to content

Commit

Permalink
Impliments slurm rest API (#130)
Browse files Browse the repository at this point in the history
* Create JWT key

* Add jwt alt auth to slurm confs for 22.05.11

* Start slurmrestd

* background slurmrestd

* Add jwt alt auth to slurm confs for 20.11.9, 22.05.2, 23.02.5

---------

Co-authored-by: Troy Caro <[email protected]>
  • Loading branch information
djperrefort and iamtroy412 authored Apr 17, 2024
1 parent 3756b82 commit 278e2d0
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The following services are automatically launched when spinning up a new contain
- `munge`
- `slurmdbd`
- `slurmctld`
- `slurmrestd`

### Python versions

Expand Down
12 changes: 10 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ echo "Create munge key..."
echo "Starting munge..."
/usr/sbin/runuser -u munge -- /usr/sbin/munged

echo "Creating JWT key..."
mkdir -p /var/slurmstate
chown slurm /var/slurmstate
/bin/dd if=/dev/random of=/var/slurmstate/jwt_hs256.key bs=32 count=1
chown slurm:slurm /var/slurmstate/jwt_hs256.key
chmod 0600 /var/slurmstate/jwt_hs256.key

echo "Starting slurmdbd..."
/usr/sbin/slurmdbd
sleep 3 # Wait for slurmdbd to start up

echo "Starting slurmctld..."
mkdir -p /var/slurmstate
chown slurm /var/slurmstate
/usr/sbin/slurmctld -c

# Wait for slurmctld to start up
Expand All @@ -40,6 +45,9 @@ do
((timeout=timeout+5));
done

echo "Starting slurmrestd..."
SLURM_JWT=daemon /usr/sbin/slurmrestd -u slurm 0.0.0.0:6820 &

if [ "$(sacctmgr show -np account account1)" ]; then
echo "Mock accounts already exist"
else
Expand Down
2 changes: 2 additions & 0 deletions slurm_config/20.11.9/slurm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ControlMachine=localhost
#BackupAddr=
#
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
#CheckpointType=checkpoint/none
CryptoType=crypto/munge
#DisableRootJobs=NO
Expand Down
4 changes: 3 additions & 1 deletion slurm_config/20.11.9/slurmdbd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ArchiveScript=/usr/sbin/slurm.dbd.archive
#AuthInfo=/var/run/munge/munge.socket.2
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
DbdHost=localhost
#DbdAddr=
#DbdPort=6819
Expand All @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid
SlurmUser=slurm
#StoragePass=password
StorageType=accounting_storage/mysql
StorageUser=slurm
StorageUser=slurm
2 changes: 2 additions & 0 deletions slurm_config/22.05.11/slurm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ControlMachine=localhost
#BackupAddr=
#
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
#CheckpointType=checkpoint/none
CryptoType=crypto/munge
#DisableRootJobs=NO
Expand Down
4 changes: 3 additions & 1 deletion slurm_config/22.05.11/slurmdbd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ArchiveScript=/usr/sbin/slurm.dbd.archive
#AuthInfo=/var/run/munge/munge.socket.2
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
DbdHost=localhost
#DbdAddr=
#DbdPort=6819
Expand All @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid
SlurmUser=slurm
#StoragePass=password
StorageType=accounting_storage/mysql
StorageUser=slurm
StorageUser=slurm
2 changes: 2 additions & 0 deletions slurm_config/22.05.2/slurm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ControlMachine=localhost
#BackupAddr=
#
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
#CheckpointType=checkpoint/none
CryptoType=crypto/munge
#DisableRootJobs=NO
Expand Down
4 changes: 3 additions & 1 deletion slurm_config/22.05.2/slurmdbd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ArchiveScript=/usr/sbin/slurm.dbd.archive
#AuthInfo=/var/run/munge/munge.socket.2
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
DbdHost=localhost
#DbdAddr=
#DbdPort=6819
Expand All @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid
SlurmUser=slurm
#StoragePass=password
StorageType=accounting_storage/mysql
StorageUser=slurm
StorageUser=slurm
2 changes: 2 additions & 0 deletions slurm_config/23.02.5/slurm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ControlMachine=localhost
#BackupAddr=
#
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
#CheckpointType=checkpoint/none
CryptoType=crypto/munge
#DisableRootJobs=NO
Expand Down
4 changes: 3 additions & 1 deletion slurm_config/23.02.5/slurmdbd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ArchiveScript=/usr/sbin/slurm.dbd.archive
#AuthInfo=/var/run/munge/munge.socket.2
AuthType=auth/munge
AuthAltTypes=auth/jwt
AuthAltParameters=jwt_key=/var/slurmstate/jwt_hs256.key,disable_token_creation
DbdHost=localhost
#DbdAddr=
#DbdPort=6819
Expand All @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid
SlurmUser=slurm
#StoragePass=password
StorageType=accounting_storage/mysql
StorageUser=slurm
StorageUser=slurm

0 comments on commit 278e2d0

Please sign in to comment.