]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add an option to keep machines locked if a test fails.
authorJosh Durgin <josh.durgin@dreamhost.com>
Mon, 11 Jul 2011 22:48:42 +0000 (15:48 -0700)
committerJosh Durgin <josh.durgin@dreamhost.com>
Mon, 11 Jul 2011 23:23:05 +0000 (16:23 -0700)
teuthology/run.py
teuthology/task/internal.py

index 1ca335039c6d51bf9a9fd83ac530e9b0a5aba56b..539aa5621b193110851cea6337046e5a8020992a 100644 (file)
@@ -60,6 +60,12 @@ def parse_args():
         default=False,
         help='block until locking machines succeeds (use with --lock)',
         )
+    parser.add_argument(
+        '--keep-locked-on-error',
+        action='store_true',
+        default=False,
+        help='unlock machines only if the test succeeds (use with --lock)',
+        )
 
     args = parser.parse_args()
     return args
@@ -84,6 +90,9 @@ def main():
     if ctx.block:
         assert ctx.lock, \
             'the --block option is only supported with the --lock option'
+    if ctx.keep_locked_on_error:
+        assert ctx.lock, \
+            'the --keep_locked_on_error option is only supported with the --lock option'
 
     from teuthology.misc import read_config
     read_config(ctx)
index 70e94be237a1b2580cefbc5a3df0ed1936764a5e..4c8341f9a79d810158fddc6c283a3c9381c28fe3 100644 (file)
@@ -70,9 +70,10 @@ def lock_machines(ctx, config):
     try:
         yield
     finally:
-        log.info('Unlocking machines...')
-        for machine in ctx.config['targets']:
-            lock.unlock(ctx, machine, ctx.owner)
+        if ctx.summary['success'] or not ctx.keep_locked_on_error:
+            log.info('Unlocking machines...')
+            for machine in ctx.config['targets']:
+                lock.unlock(ctx, machine, ctx.owner)
 
 def check_lock(ctx, config):
     log.info('Checking locks...')