From ba956d3bb39eb16e2da6c9157929d4c75596697d Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 6 Mar 2017 15:40:05 -0800 Subject: [PATCH] provision: invoke downburst with -v and --logfile Verbose output isn't verbose enough to matter, and can be helpful tracking down weirdness. Also, log to private file in case downburst hangs mid-operation, to avoid having to do any select() madness in teuthology. Signed-off-by: Dan Mick --- teuthology/provision/__init__.py | 13 +++++++++++-- teuthology/provision/downburst.py | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/teuthology/provision/__init__.py b/teuthology/provision/__init__.py index 8c81e5bd27..b7b535962d 100644 --- a/teuthology/provision/__init__.py +++ b/teuthology/provision/__init__.py @@ -6,11 +6,18 @@ from ..misc import decanonicalize_hostname, get_distro, get_distro_version import cloud import downburst import openstack +import os log = logging.getLogger(__name__) +def _logfile(ctx, shortname): + if (ctx.config.get('archive_path')): + return os.path.join(ctx.config['archive_path'], + shortname + '.downburst.log') + + def create_if_vm(ctx, machine_name, _downburst=None): """ Use downburst to create a virtual machine @@ -45,7 +52,8 @@ def create_if_vm(ctx, machine_name, _downburst=None): dbrst = _downburst or \ downburst.Downburst(name=machine_name, os_type=os_type, - os_version=os_version, status=status_info) + os_version=os_version, status=status_info, + logfile=_logfile(ctx, shortname)) return dbrst.create() @@ -87,5 +95,6 @@ def destroy_if_vm(ctx, machine_name, user=None, description=None, dbrst = _downburst or \ downburst.Downburst(name=machine_name, os_type=None, - os_version=None, status=status_info) + os_version=None, status=status_info, + logfile=_logfile(ctx, shortname)) return dbrst.destroy() diff --git a/teuthology/provision/downburst.py b/teuthology/provision/downburst.py index b973c6f0b4..514f38b65e 100644 --- a/teuthology/provision/downburst.py +++ b/teuthology/provision/downburst.py @@ -42,7 +42,8 @@ class Downburst(object): A class that provides methods for creating and destroying virtual machine instances using downburst: https://github.com/ceph/downburst """ - def __init__(self, name, os_type, os_version, status=None, user='ubuntu'): + def __init__(self, name, os_type, os_version, status=None, user='ubuntu', + logfile=None): self.name = name self.shortname = decanonicalize_hostname(self.name) self.os_type = os_type @@ -51,6 +52,7 @@ class Downburst(object): self.config_path = None self.user_path = None self.user = user + self.logfile = logfile self.host = decanonicalize_hostname(self.status['vm_host']['name']) self.executable = downburst_executable() @@ -100,15 +102,16 @@ class Downburst(object): if not self.user_path: raise ValueError("I need a user_path!") - args = [ - self.executable, - '-c', self.host, + args = [self.executable, '-v', '-c', self.host] + if self.logfile: + args.extend(['-l', self.logfile]) + args.extend([ 'create', '--wait', '--meta-data=%s' % self.config_path, '--user-data=%s' % self.user_path, self.shortname, - ] + ]) log.info("Provisioning a {distro} {distroversion} vps".format( distro=self.os_type, distroversion=self.os_version @@ -126,7 +129,10 @@ class Downburst(object): if not executable: log.error("No downburst executable found.") return False - args = [executable, '-c', self.host, 'destroy', self.shortname] + args = [executable, '-v', '-c', self.host] + if self.logfile: + args.extend(['-l', self.logfile]) + args.extend(['destroy', self.shortname]) proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,) out, err = proc.communicate() -- 2.39.5