From 5d945fb71e592e0677f93831013290a579319434 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sun, 25 Dec 2016 16:45:36 +0000 Subject: [PATCH] qa/vstart_runner: more robust stop() on daemons Previously this could get hung up if we killed one PID and then the daemon reappears with a different one (perhaps because we caught it during daemonization?) Signed-off-by: John Spray --- qa/tasks/vstart_runner.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 629c89162b9..05ff7d9c325 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -343,6 +343,25 @@ class LocalDaemon(object): pid = self._get_pid() log.info("Killing PID {0} for {1}.{2}".format(pid, self.daemon_type, self.daemon_id)) os.kill(pid, signal.SIGKILL) + + waited = 0 + while pid is not None: + new_pid = self._get_pid() + if new_pid is not None and new_pid != pid: + log.info("Killing new PID {0}".format(new_pid)) + pid = new_pid + os.kill(pid, signal.SIGKILL) + + if new_pid is None: + break + else: + if waited > timeout: + raise MaxWhileTries( + "Timed out waiting for daemon {0}.{1}".format( + self.daemon_type, self.daemon_id)) + time.sleep(1) + waited += 1 + self.wait(timeout=timeout) def restart(self):