Skip to content

Commit 5189966

Browse files
committed
Correcting slurm restart logic
Fixing Slurm restart in Master and compute nodes. With respect to compute node restart, we are checking path existence in master node which is wrong, now moved this logic to command line so it executes in compute node. And in Master slurm restart we need to pass restart command as list. Signed-off-by: Mohan Gandhi <[email protected]>
1 parent 5ec9f57 commit 5189966

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

sqswatcher/plugins/slurm.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from tempfile import mkstemp
1414
from shutil import move
1515
import os
16+
import os.path
1617
import paramiko
1718
import socket
1819
import time
@@ -56,11 +57,7 @@ def __restartSlurm(hostname, cluster_user):
5657
ssh._host_keys_filename = None
5758
pass
5859
ssh.save_host_keys(hosts_key_file)
59-
slurmRestart = Path('/etc/systemd/system/slurmd.service')
60-
if slurmRestart.is_file():
61-
command = 'sudo systemctl restart slurmctld.service'
62-
else:
63-
command = 'sudo sh -c \"/etc/init.d/slurm restart 2>&1 > /tmp/slurmdstart.log\"'
60+
command = 'if [ -f /etc/systemd/system/slurmd.service ]; then sudo systemctl restart slurmd.service; else sudo sh -c \"/etc/init.d/slurm restart 2>&1 > /tmp/slurmdstart.log\"; fi'
6461

6562
stdin, stdout, stderr = ssh.exec_command(command)
6663
while not stdout.channel.exit_status_ready():
@@ -158,9 +155,8 @@ def removeHost(hostname, cluster_user):
158155

159156

160157
def restartMasterNodeSlurm():
161-
slurmRestart = Path('/etc/systemd/system/slurmctld.service')
162-
if slurmRestart.is_file():
163-
command = 'sudo systemctl restart slurmctld.service'
158+
if os.path.isfile('/etc/systemd/system/slurmctld.service'):
159+
command = ['sudo', 'systemctl', 'restart', 'slurmctld.service']
164160
else:
165161
command = ['/etc/init.d/slurm', 'restart']
166162
__runCommand(command)

0 commit comments

Comments
 (0)