From 6eea314df83fdbefd5bd24ea94623697dc93314b Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 29 Aug 2014 17:40:48 +0100 Subject: [PATCH] nuke: kill hadoop processes Signed-off-by: John Spray --- teuthology/nuke.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/teuthology/nuke.py b/teuthology/nuke.py index df549412ec..2b14a0d9c7 100644 --- a/teuthology/nuke.py +++ b/teuthology/nuke.py @@ -4,6 +4,7 @@ import os import subprocess import time import yaml +from StringIO import StringIO import teuthology from . import orchestra @@ -74,6 +75,21 @@ def shutdown_daemons(ctx): proc.wait() +def kill_hadoop(ctx): + for remote in ctx.cluster.remotes.iterkeys(): + pids_out = StringIO() + ps_proc = remote.run(args=[ + "ps", "-eo", "pid,cmd", + run.Raw("|"), "grep", "java.*hadoop", + run.Raw("|"), "grep", "-v", "grep" + ], stdout=pids_out, check_status=False) + + if ps_proc.exitstatus == 0: + for line in pids_out.getvalue().strip().split("\n"): + pid, cmdline = line.split(None, 1) + log.info("Killing PID {0} ({1})".format(pid, cmdline)) + remote.run(args=["kill", "-9", pid], check_status=False) + def find_kernel_mounts(ctx): nodes = {} log.info('Looking for kernel mounts to handle...') @@ -453,6 +469,8 @@ def nuke_helper(ctx, should_unlock): remove_osd_tmpfs(ctx) # log.info('Dealing with any kernel mounts...') # remove_kernel_mounts(ctx, need_reboot) + log.info("Terminating Hadoop services...") + kill_hadoop(ctx) if need_reboot: reboot(ctx, need_reboot) -- 2.39.5