Skip to content

Commit

Permalink
Fixed missing environment variables in power up/down scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wtripp180901 committed Aug 17, 2023
1 parent 63795d3 commit a731c60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 7 additions & 5 deletions image/k8s-slurmd-create
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

echo "$(date) Resume invoked $0 $*" &>> /var/log/slurm/power_save.log

echo "Arguments: $* $0 $1" &>> /var/log/slurm/power_save.log
APISERVER=https://kubernetes.default.svc
SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount
NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace)
TOKEN=$(cat ${SERVICEACCOUNT}/token)
CACERT=${SERVICEACCOUNT}/ca.crt

hosts=$(scontrol show hostnames $1) # this is purely a textual expansion, doens't depend on defined nodes
echo "Powering up hosts: $hosts" &>> /var/log/slurm/power_save.log
for host in $hosts
do
echo "Creating $host" &>> /var/log/slurm/power_save.log
( sed s/SLURMD_NODENAME/$host/ /etc/slurm/slurmd-pod-template.yml | kubectl create -f - ) &>> /var/log/slurm/power_save.log
echo "done" &>> /var/log/slurm/power_save.log
( sed s/SLURMD_NODENAME/$host/ /etc/slurm/slurmd-pod-template.yml | \
kubectl --server $APISERVER --token $TOKEN --certificate-authority $CACERT create -f - )
done
9 changes: 7 additions & 2 deletions image/k8s-slurmd-delete
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/bash
set -euo pipefail

echo "$(date) Suspend invoked $0 $*" >> /var/log/slurm/power_save.log

APISERVER=https://kubernetes.default.svc
SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount
NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace)
TOKEN=$(cat ${SERVICEACCOUNT}/token)
CACERT=${SERVICEACCOUNT}/ca.crt

hosts=$(scontrol show hostnames $1) # this is purely a textual expansion, doens't depend on defined nodes
for host in $hosts
do
kubectl delete pod $host
kubectl --server $APISERVER --token $TOKEN --certificate-authority $CACERT delete pod $host
done

0 comments on commit a731c60

Please sign in to comment.