From 278e2d033719cf9f586fa2dc73cae067f635a35a Mon Sep 17 00:00:00 2001 From: Daniel Perrefort Date: Wed, 17 Apr 2024 19:55:18 -0400 Subject: [PATCH] Impliments slurm rest API (#130) * 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 --- README.md | 1 + entrypoint.sh | 12 ++++++++++-- slurm_config/20.11.9/slurm.conf | 2 ++ slurm_config/20.11.9/slurmdbd.conf | 4 +++- slurm_config/22.05.11/slurm.conf | 2 ++ slurm_config/22.05.11/slurmdbd.conf | 4 +++- slurm_config/22.05.2/slurm.conf | 2 ++ slurm_config/22.05.2/slurmdbd.conf | 4 +++- slurm_config/23.02.5/slurm.conf | 2 ++ slurm_config/23.02.5/slurmdbd.conf | 4 +++- 10 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a4d5fb8..5f3cfbe 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ The following services are automatically launched when spinning up a new contain - `munge` - `slurmdbd` - `slurmctld` +- `slurmrestd` ### Python versions diff --git a/entrypoint.sh b/entrypoint.sh index c8c7764..152af7d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 @@ -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 diff --git a/slurm_config/20.11.9/slurm.conf b/slurm_config/20.11.9/slurm.conf index 51d3211..b2e63f8 100644 --- a/slurm_config/20.11.9/slurm.conf +++ b/slurm_config/20.11.9/slurm.conf @@ -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 diff --git a/slurm_config/20.11.9/slurmdbd.conf b/slurm_config/20.11.9/slurmdbd.conf index ed1d4a9..9d5cb92 100644 --- a/slurm_config/20.11.9/slurmdbd.conf +++ b/slurm_config/20.11.9/slurmdbd.conf @@ -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 @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid SlurmUser=slurm #StoragePass=password StorageType=accounting_storage/mysql -StorageUser=slurm \ No newline at end of file +StorageUser=slurm diff --git a/slurm_config/22.05.11/slurm.conf b/slurm_config/22.05.11/slurm.conf index 2ad45f4..84d24a4 100644 --- a/slurm_config/22.05.11/slurm.conf +++ b/slurm_config/22.05.11/slurm.conf @@ -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 diff --git a/slurm_config/22.05.11/slurmdbd.conf b/slurm_config/22.05.11/slurmdbd.conf index ed1d4a9..9d5cb92 100644 --- a/slurm_config/22.05.11/slurmdbd.conf +++ b/slurm_config/22.05.11/slurmdbd.conf @@ -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 @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid SlurmUser=slurm #StoragePass=password StorageType=accounting_storage/mysql -StorageUser=slurm \ No newline at end of file +StorageUser=slurm diff --git a/slurm_config/22.05.2/slurm.conf b/slurm_config/22.05.2/slurm.conf index 2ad45f4..84d24a4 100644 --- a/slurm_config/22.05.2/slurm.conf +++ b/slurm_config/22.05.2/slurm.conf @@ -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 diff --git a/slurm_config/22.05.2/slurmdbd.conf b/slurm_config/22.05.2/slurmdbd.conf index ed1d4a9..9d5cb92 100644 --- a/slurm_config/22.05.2/slurmdbd.conf +++ b/slurm_config/22.05.2/slurmdbd.conf @@ -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 @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid SlurmUser=slurm #StoragePass=password StorageType=accounting_storage/mysql -StorageUser=slurm \ No newline at end of file +StorageUser=slurm diff --git a/slurm_config/23.02.5/slurm.conf b/slurm_config/23.02.5/slurm.conf index 2ad45f4..84d24a4 100644 --- a/slurm_config/23.02.5/slurm.conf +++ b/slurm_config/23.02.5/slurm.conf @@ -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 diff --git a/slurm_config/23.02.5/slurmdbd.conf b/slurm_config/23.02.5/slurmdbd.conf index ed1d4a9..9d5cb92 100644 --- a/slurm_config/23.02.5/slurmdbd.conf +++ b/slurm_config/23.02.5/slurmdbd.conf @@ -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 @@ -20,4 +22,4 @@ PidFile=/var/run/slurmdbd.pid SlurmUser=slurm #StoragePass=password StorageType=accounting_storage/mysql -StorageUser=slurm \ No newline at end of file +StorageUser=slurm