]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
nuke: be more careful about kill; simplify
authorSage Weil <sage@newdream.net>
Tue, 3 Jul 2012 23:22:38 +0000 (16:22 -0700)
committerSage Weil <sage@newdream.net>
Wed, 4 Jul 2012 21:47:33 +0000 (14:47 -0700)
If the archive dir is specified, make sure we are killing the right
process.

Also drop the kill_process helper; it's simple enough to open-code.

teuthology/misc.py
teuthology/nuke.py

index db3133cf974379b841a3a56833f2deec0d3fd8ee..33f9b5169738622de52eb364873628c3250be421 100644 (file)
@@ -424,9 +424,6 @@ 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 = {}
index 09a84f911131c2edda8da4f1a69408278ac24e24..b1f1baf0d917b9894a2957ea3f5199f49e4541ec 100644 (file)
@@ -33,7 +33,7 @@ def parse_args():
         '-p','--pid',
        type=int,
        default=False,
-        help='pid of the process to be deleted',
+        help='pid of the process to be killed',
         )
     parser.add_argument(
         '-r', '--reboot-all',
@@ -262,7 +262,7 @@ def main():
     if ctx.archive:
         ctx.config = config_file(ctx.archive + '/config.yaml')
         if not ctx.pid:
-            ctx.pid = int open(ctx.archive + '/pid').read().rstrip('\n')
+            ctx.pid = int(open(ctx.archive + '/pid').read().rstrip('\n'))
         if not ctx.owner:
             ctx.owner = open(ctx.archive + '/owner').read().rstrip('\n')
 
@@ -276,8 +276,13 @@ def main():
         ctx.owner = get_user()
 
     if ctx.pid:
-       from teuthology.misc import kill_process
-       kill_process(ctx)
+        if ctx.archive:
+            import os
+            os.system('grep -q %s /proc/%d/cmdline && kill %d' % (ctx.archive,
+                                                                  ctx.pid,
+                                                                  ctx.pid))
+        else:
+            subprocess.check_call(["kill", "-9", str(ctx.pid)]);
 
     nuke(ctx, log, ctx.unlock, ctx.synch_clocks, ctx.reboot_all)