From 4a864f39b7fd67ac9592fe7735737f0228a04177 Mon Sep 17 00:00:00 2001 From: Steven Dick Date: Thu, 17 Mar 2016 00:34:27 -0400 Subject: [PATCH 1/2] Don't abort insert-ethers --remove if the host isn't found in the sge config Repeat bug by: add a new node ...some time later, hardware dies upgrade cluster and use the upgrade roll try to delete the dead node not yet re-added to sge --- src/rocks-command/remove/host/plugin_sge.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rocks-command/remove/host/plugin_sge.py b/src/rocks-command/remove/host/plugin_sge.py index 70d8ceb..847fdb2 100644 --- a/src/rocks-command/remove/host/plugin_sge.py +++ b/src/rocks-command/remove/host/plugin_sge.py @@ -94,6 +94,7 @@ import subprocess import shlex import rocks.commands +import syslog class Plugin(rocks.commands.Plugin): @@ -112,6 +113,7 @@ def run(self, host): # remove the host from every defined SGE 'host group' # cmd = 'qconf -shgrpl' + try: p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) @@ -132,4 +134,6 @@ def run(self, host): stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + except: + syslog.syslog(syslog.LOG_INFO, 'sge remove fail for %s' % host) From 328e50f2bc50d5b11447feca58288dbff181c512 Mon Sep 17 00:00:00 2001 From: Steven Dick Date: Thu, 17 Mar 2016 00:43:52 -0400 Subject: [PATCH 2/2] fix indention --- src/rocks-command/remove/host/plugin_sge.py | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/rocks-command/remove/host/plugin_sge.py b/src/rocks-command/remove/host/plugin_sge.py index 847fdb2..eb5cb5b 100644 --- a/src/rocks-command/remove/host/plugin_sge.py +++ b/src/rocks-command/remove/host/plugin_sge.py @@ -114,26 +114,26 @@ def run(self, host): # cmd = 'qconf -shgrpl' try: - p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, - stdout = subprocess.PIPE, stderr = subprocess.PIPE) + p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, + stdout = subprocess.PIPE, stderr = subprocess.PIPE) - for group in p.stdout.readlines(): - cmd = 'qconf -dattr hostgroup hostlist %s %s' % \ - (host, group) + for group in p.stdout.readlines(): + cmd = 'qconf -dattr hostgroup hostlist %s %s' % \ + (host, group) + p = subprocess.Popen(shlex.split(cmd), + stdin = subprocess.PIPE, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE) + + # + # remove the host as a SGE 'execution host' + # + cmd = 'qconf -de %s' % host p = subprocess.Popen(shlex.split(cmd), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE) - - # - # remove the host as a SGE 'execution host' - # - cmd = 'qconf -de %s' % host - p = subprocess.Popen(shlex.split(cmd), - stdin = subprocess.PIPE, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) except: syslog.syslog(syslog.LOG_INFO, 'sge remove fail for %s' % host)