]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
New internal task to check packages and fail the job if any are missing
authorAndrew Schoen <aschoen@redhat.com>
Mon, 12 Jan 2015 17:22:11 +0000 (11:22 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 15 Jan 2015 20:18:35 +0000 (14:18 -0600)
Introduces a new task, internal.check_packages, that checks gitbuilder
for ceph packages for the given os_type and sha1 defined in the job
config.  If no packages are found, fail the job. This new task is ran
before any other tasks.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
teuthology/run.py
teuthology/task/internal.py

index a0f75339cef4ab166dc0e9afb3aa1ef7b12ba582..5de21caebd5a287c3f17e295663814bb647dd2e9 100644 (file)
@@ -168,7 +168,7 @@ def validate_tasks(config):
 
 
 def get_initial_tasks(lock, config, machine_type):
-    init_tasks = []
+    init_tasks = [{'internal.check_packages': None}]
     if lock:
         msg = ('You cannot specify targets in a config file when using the ' +
                '--lock option')
index 2f50902f97851d7b1ad14f1f173d05ce06b9df6d..dffba820c6d7ca66293bee217dcbe99463c54cf9 100644 (file)
@@ -18,6 +18,7 @@ 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 teuthology.suite import has_packages_for_distro
 from ..orchestra import cluster, remote, run
 from .. import report
 
@@ -201,6 +202,47 @@ def check_lock(ctx, config):
             owner=ctx.owner,
             )
 
+
+def check_packages(ctx, config):
+    """
+    Checks gitbuilder to determine if there are missing packages for this job.
+
+    If there are missing packages, fail the job.
+    """
+    log.info("Checking packages...")
+    os_type = ctx.config.get("os_type", None)
+    sha1 = ctx.config.get("sha1", None)
+    # We can only do this check if there are a defined sha1 and os_type
+    # in the job config.
+    if os_type and sha1:
+        log.info(
+            "Checking packages for os_type '{os}' and ceph hash '{ver}'".format(
+                os=os_type,
+                ver=sha1,
+            )
+        )
+        if not has_packages_for_distro(sha1, os_type):
+            msg = "Packages for os_type '{os}' and ceph hash '{ver}' not found"
+            msg = msg.format(
+                os=os_type,
+                ver=sha1,
+            )
+            log.error(msg)
+            # set the failure message and update paddles with the status
+            ctx.summary["failure_reason"] = msg
+            set_status(ctx.summary, "dead")
+            report.try_push_job_info(ctx.config, dict(status='dead'))
+            raise RuntimeError(msg)
+    else:
+        log.info(
+            "Checking packages skipped, missing os_type '{os}' or ceph hash '{ver}'".format(
+                os=os_type,
+                ver=sha1,
+            )
+        )
+
+
+
 @contextlib.contextmanager
 def timer(ctx, config):
     """