]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
nuke: Use pkill -KILL to unconditionally wipe out hadoop processes 1004/head
authorNathan Cutler <ncutler@suse.com>
Tue, 27 Dec 2016 10:43:15 +0000 (11:43 +0100)
committerNathan Cutler <ncutler@suse.com>
Tue, 27 Dec 2016 10:55:32 +0000 (11:55 +0100)
In CentOS 7, the command "ps -ef | grep 'java.*hadoop' | grep -v grep | awk
'{print $2}' | xargs kill -9" produces undesirable output when no matching
processes exist.

Note: the "-f" option to pkill mimics the semantics of "ps -ef". For example,
"ps -ef | grep 'java.*hadoop'" will match a process called "sh java343hadoop",
while pkill will match that process only with the -f option:

$ ps -ef | grep "java.*hadoop" | grep -v grep
root     16165  4101  0 11:57 pts/1    00:00:00 sh java343hadoop
$ pkill -KILL "java.*hadoop"
$
$ ps -ef | grep "java.*hadoop" | grep -v grep
root     16165  4101  0 11:57 pts/1    00:00:00 sh java343hadoop
$ pkill -f -KILL "java.*hadoop"
[1]+  Killed                  sh java343hadoop

Fixes: http://tracker.ceph.com/issues/17981
Signed-off-by: Nathan Cutler <ncutler@suse.com>
teuthology/nuke/actions.py

index 2de8b49a7d6a0389a08ccd7148ba1ecef7486465..fa327fe4b667810236da742d4ba5b9cd3d9cef4f 100644 (file)
@@ -75,11 +75,7 @@ def shutdown_daemons(ctx):
 def kill_hadoop(ctx):
     log.info("Terminating Hadoop services...")
     ctx.cluster.run(args=[
-        "ps", "-ef",
-        run.Raw("|"), "grep", "java.*hadoop",
-        run.Raw("|"), "grep", "-v", "grep",
-        run.Raw("|"), 'awk', '{print $2}',
-        run.Raw("|"), 'xargs', 'kill', '-9',
+        "pkill", "-f", "-KILL", "java.*hadoop",
         ],
         check_status=False,
         timeout=60