From: tamil Date: Tue, 3 Jul 2012 19:22:26 +0000 (-0700) Subject: nuke - optionally kill the process hung X-Git-Tag: 1.1.0~2519 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3c24517977f356f9b1114dd952db74aadc9e521;p=teuthology.git nuke - optionally kill the process hung Added a function kill_process to kill the process hung in the nightly runs. It takes in pid as an optional argument. Signed-off-by: tamil --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 22f503c24..5c6c11392 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -10,6 +10,7 @@ import urllib2 import urlparse import yaml import json +import subprocess from .orchestra import run @@ -423,6 +424,9 @@ def get_clients(ctx, roles): def get_user(): return getpass.getuser() + '@' + socket.gethostname() +def kill_process(ctx): + subprocess.check_call(["kill", "-9", str(ctx.pid)]); + def read_config(ctx): filename = os.path.join(os.environ['HOME'], '.teuthology.yaml') ctx.teuthology_config = {} diff --git a/teuthology/nuke.py b/teuthology/nuke.py index 8cd704b62..8aa5b8b74 100644 --- a/teuthology/nuke.py +++ b/teuthology/nuke.py @@ -30,6 +30,12 @@ def parse_args(): '--owner', help='job owner', ) + parser.add_argument( + '-p','--pid', + type=int, + default=False, + help='pid of the process to be deleted', + ) parser.add_argument( '-r', '--reboot-all', action='store_true', @@ -262,8 +268,11 @@ def main(): from teuthology.misc import get_user ctx.owner = get_user() - nuke(ctx, log, ctx.unlock, ctx.synch_clocks, ctx.reboot_all) + if ctx.pid: + from teuthology.misc import kill_process + kill_process(ctx) + nuke(ctx, log, ctx.unlock, ctx.synch_clocks, ctx.reboot_all) def nuke(ctx, log, should_unlock, sync_clocks=True, reboot_all=True): from teuthology.parallel import parallel