From: Zack Cerza Date: Thu, 22 May 2014 17:26:50 +0000 (-0500) Subject: Don't crash when an invalid branch is passed X-Git-Tag: v0.94.10~27^2^2~364^2~144 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d3c230071a23354d6acfb44d26e1c4559b9a6bdf;p=ceph.git Don't crash when an invalid branch is passed Signed-off-by: Zack Cerza --- diff --git a/teuthology/worker.py b/teuthology/worker.py index e74167c06903..111706ed32f3 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -75,6 +75,14 @@ class filelock(object): self.fd = None +class BranchNotFoundError(ValueError): + def __init__(self, branch): + self.branch = branch + + def __str__(self): + return "teuthology branch not found: '{0}'".format(self.branch) + + def fetch_teuthology_branch(path, branch='master'): """ Make sure we have the correct teuthology branch checked out and up-to-date @@ -113,9 +121,8 @@ def fetch_teuthology_branch(path, branch='master'): cwd=path, ) except subprocess.CalledProcessError: - log.exception("teuthology branch not found: %s", branch) shutil.rmtree(path) - raise + raise BranchNotFoundError(branch) log.debug("Bootstrapping %s", path) # This magic makes the bootstrap script not attempt to clobber an @@ -191,7 +198,16 @@ def main(ctx): teuth_path = os.path.join(os.getenv("HOME"), 'teuthology-' + teuthology_branch) - fetch_teuthology_branch(path=teuth_path, branch=teuthology_branch) + try: + fetch_teuthology_branch(path=teuth_path, branch=teuthology_branch) + except BranchNotFoundError: + log.exception( + "Branch not found; throwing job away") + # Optionally, we could mark the job as dead, but we don't have a + # great way to express why it is dead. + report.try_delete_jobs(job_config['name'], + job_config['job_id']) + continue teuth_bin_path = os.path.join(teuth_path, 'virtualenv', 'bin') if not os.path.isdir(teuth_bin_path):