]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Use new functions provided by job_status
authorZack Cerza <zack.cerza@inktank.com>
Thu, 16 Oct 2014 18:54:07 +0000 (12:54 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 16 Oct 2014 19:51:44 +0000 (13:51 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/ls.py
teuthology/report.py
teuthology/results.py
teuthology/run.py
teuthology/run_tasks.py
teuthology/task/internal.py

index 57c1ef55024054a25d2a2fe889842d236d92ea04..8df818b0ac67c61773ce5d0198454bf9da9b0db3 100644 (file)
@@ -3,6 +3,8 @@ import yaml
 import errno
 import re
 
+from .job_status import get_status
+
 
 def main(args):
     return ls(args.archive_dir, args.verbose)
@@ -47,11 +49,11 @@ def ls(archive_dir, verbose):
             else:
                 raise
 
-        print "{job} {success} {owner} {desc} {duration}s".format(
+        print "{job} {status} {owner} {desc} {duration}s".format(
             job=j,
             owner=summary.get('owner', '-'),
             desc=summary.get('description', '-'),
-            success='pass' if summary.get('success', False) else 'FAIL',
+            status=get_status(summary),
             duration=int(summary.get('duration', 0)),
         )
         if verbose and 'failure_reason' in summary:
index 7f052594b2da6e5365b3cecaf24c7e3c9359ad0a..51440164897a6b5c122533a0ace118570423ac30 100644 (file)
@@ -9,6 +9,7 @@ from datetime import datetime
 
 import teuthology
 from .config import config
+from .job_status import get_status, set_status
 
 report_exceptions = (requests.exceptions.RequestException, socket.error)
 
@@ -288,8 +289,8 @@ class ResultsReporter(object):
             base=self.base_uri, name=run_name,)
         if job_info is None:
             job_info = self.serializer.job_info(run_name, job_id)
-        if dead and job_info.get('success') is None:
-            job_info['status'] = 'dead'
+        if dead and get_status(job_info) is None:
+            set_status(job_info, 'dead')
         job_json = json.dumps(job_info)
         headers = {'content-type': 'application/json'}
         response = self.session.post(run_uri, data=job_json, headers=headers)
index 586a6c5e5cded11aaf20ff4f4afad276a9f343f7..4669b62e52cbb8ae9229da2ac20f998f3d8d66df 100644 (file)
@@ -10,6 +10,7 @@ from textwrap import fill
 import teuthology
 from teuthology import misc
 from teuthology import ls
+from .job_status import get_status
 from .report import ResultsSerializer
 
 log = logging.getLogger(__name__)
@@ -131,7 +132,7 @@ def build_email_body(name, archive_dir, timeout):
         with file(summary_file) as f:
             summary = yaml.safe_load(f)
 
-        if summary['success']:
+        if get_status(summary) == 'pass':
             passed[job] = email_templates['pass_templ'].format(
                 job_id=job,
                 desc=summary.get('description'),
index 64cb5138543bbd76eea1dab084e80c439cab67b5..714153aeff4d2d45074a6d0dc7d8677005086a34 100644 (file)
@@ -8,6 +8,7 @@ from traceback import format_tb
 
 import teuthology
 from . import report
+from .job_status import get_status, set_status
 from .misc import get_user
 from .misc import read_config
 from .nuke import nuke
@@ -131,7 +132,8 @@ def main(ctx):
     log.debug('\n  '.join(['Config:', ] + yaml.safe_dump(
         ctx.config, default_flow_style=False).splitlines()))
 
-    ctx.summary = dict(success=True)
+    ctx.summary = dict(status='pass')
+    set_status(ctx.summary, 'pass')
 
     ctx.summary['owner'] = ctx.owner
 
@@ -185,7 +187,9 @@ def main(ctx):
     try:
         run_tasks(tasks=ctx.config['tasks'], ctx=ctx)
     finally:
-        if not ctx.summary.get('success') and bool(ctx.config.get('nuke-on-error')):
+        status = get_status(ctx.summary)
+        passed = status == 'pass'
+        if not passed and bool(ctx.config.get('nuke-on-error')):
             # only unlock if we locked them in the first place
             nuke(ctx, ctx.lock)
         if ctx.archive is not None:
@@ -196,7 +200,7 @@ def main(ctx):
             log.info('Summary data:\n%s' % f.getvalue())
         with contextlib.closing(StringIO.StringIO()) as f:
             if ('email-on-error' in ctx.config
-                    and not ctx.summary.get('success', False)):
+                    and not passed):
                 yaml.safe_dump(ctx.summary, f)
                 yaml.safe_dump(ctx.config, f)
                 emsg = f.getvalue()
@@ -207,8 +211,8 @@ def main(ctx):
 
         report.try_push_job_info(ctx.config, ctx.summary)
 
-        if ctx.summary.get('success', True):
-            log.info('pass')
+        if passed:
+            log.info(status)
         else:
-            log.info('FAIL')
+            log.info(str(status).upper())
             sys.exit(1)
index fd379fe5592dd656ab63ee89e017e9d5cd444f5e..588e7ea6c208e832c9f48430e8edbe4cde2d1279 100644 (file)
@@ -1,6 +1,7 @@
 import sys
 import logging
 from .sentry import get_client as get_sentry_client
+from .job_status import set_status
 from .misc import get_http_log_path
 from .config import config as teuth_config
 from .exceptions import ConnectionLostError
@@ -54,10 +55,11 @@ def run_tasks(tasks, ctx):
                 manager.__enter__()
                 stack.append((taskname, manager))
     except BaseException as e:
-        ctx.summary['success'] = False
         if isinstance(e, ConnectionLostError):
             # Prevent connection issues being flagged as failures
-            ctx.summary['status'] = 'dead'
+            set_status(ctx.summary, 'dead')
+        else:
+            set_status(ctx.summary, 'fail')
         if 'failure_reason' not in ctx.summary:
             ctx.summary['failure_reason'] = str(e)
         log.exception('Saw exception from tasks.')
@@ -116,10 +118,11 @@ def run_tasks(tasks, ctx):
                 try:
                     suppress = manager.__exit__(*exc_info)
                 except Exception as e:
-                    ctx.summary['success'] = False
                     if isinstance(e, ConnectionLostError):
                         # Prevent connection issues being flagged as failures
-                        ctx.summary['status'] = 'dead'
+                        set_status(ctx.summary, 'dead')
+                    else:
+                        set_status(ctx.summary, 'fail')
                     if 'failure_reason' not in ctx.summary:
                         ctx.summary['failure_reason'] = str(e)
                     log.exception('Manager failed: %s', taskname)
index efdd854e4697ea3de6bdc20f8e6f6dbc7273d86e..bb0e7a0061219d364c5b016449d5893f4b89d4e1 100644 (file)
@@ -15,6 +15,7 @@ from teuthology import lockstatus
 from teuthology import lock
 from teuthology import misc
 from teuthology import provision
+from teuthology.job_status import get_status, set_status
 from teuthology.config import config as teuth_config
 from teuthology.parallel import parallel
 from ..orchestra import cluster, remote, run
@@ -147,7 +148,7 @@ def lock_machines(ctx, config):
         yield
     finally:
         if ctx.config.get('unlock_on_failure', False) or \
-           ctx.summary.get('success', False):
+                get_status(ctx.summary) == 'pass':
             log.info('Unlocking machines...')
             for machine in ctx.config['targets'].iterkeys():
                 lock.unlock_one(ctx, machine, ctx.owner)
@@ -320,11 +321,12 @@ def archive(ctx, config):
         yield
     except Exception:
         # we need to know this below
-        ctx.summary['success'] = False
+        set_status(ctx.summary, 'fail')
         raise
     finally:
+        passed = get_status(ctx.summary) == 'pass'
         if ctx.archive is not None and \
-                not (ctx.config.get('archive-on-error') and ctx.summary['success']):
+                not (ctx.config.get('archive-on-error') and passed):
             log.info('Transferring archived files...')
             logdir = os.path.join(ctx.archive, 'remote')
             if (not os.path.exists(logdir)):
@@ -415,7 +417,7 @@ def coredump(ctx, config):
                 )
             )
 
-        # set success=false if the dir is still there = coredumps were
+        # set status = 'fail' if the dir is still there = coredumps were
         # seen
         for rem in ctx.cluster.remotes.iterkeys():
             r = rem.run(
@@ -428,7 +430,7 @@ def coredump(ctx, config):
                 )
             if r.stdout.getvalue() != 'OK\n':
                 log.warning('Found coredumps on %s, flagging run as failed', rem)
-                ctx.summary['success'] = False
+                set_status(ctx.summary, 'fail')
                 if 'failure_reason' not in ctx.summary:
                     ctx.summary['failure_reason'] = \
                         'Found coredumps on {rem}'.format(rem=rem)
@@ -545,7 +547,7 @@ kern.* -{adir}/syslog/kern.log;RSYSLOG_FileFormat
             stdout = r.stdout.getvalue()
             if stdout != '':
                 log.error('Error in syslog on %s: %s', rem.name, stdout)
-                ctx.summary['success'] = False
+                set_status(ctx.summary, 'fail')
                 if 'failure_reason' not in ctx.summary:
                     ctx.summary['failure_reason'] = \
                         "'{error}' in syslog".format(error=stdout)