]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
provision.downburst: Tweak destroy return code 1040/head
authorZack Cerza <zack@redhat.com>
Mon, 6 Mar 2017 19:35:27 +0000 (19:35 +0000)
committerZack Cerza <zack@redhat.com>
Mon, 6 Mar 2017 19:40:35 +0000 (19:40 +0000)
Specifically, if the instance doesn't even exist, consider the destroy
op to have succeeded.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/provision/downburst.py

index d9e300a9007303c3c6347d3d30acf4a3f24c54a3..b973c6f0b46f9d592ac46d6be6ca00941970d86f 100644 (file)
@@ -44,6 +44,7 @@ class Downburst(object):
     """
     def __init__(self, name, os_type, os_version, status=None, user='ubuntu'):
         self.name = name
+        self.shortname = decanonicalize_hostname(self.name)
         self.os_type = os_type
         self.os_version = os_version
         self.status = status or query.get_status(self.name)
@@ -98,7 +99,6 @@ class Downburst(object):
             raise ValueError("I need a config_path!")
         if not self.user_path:
             raise ValueError("I need a user_path!")
-        shortname = decanonicalize_hostname(self.name)
 
         args = [
             self.executable,
@@ -107,7 +107,7 @@ class Downburst(object):
             '--wait',
             '--meta-data=%s' % self.config_path,
             '--user-data=%s' % self.user_path,
-            shortname,
+            self.shortname,
         ]
         log.info("Provisioning a {distro} {distroversion} vps".format(
             distro=self.os_type,
@@ -126,12 +126,15 @@ class Downburst(object):
         if not executable:
             log.error("No downburst executable found.")
             return False
-        shortname = decanonicalize_hostname(self.name)
-        args = [executable, '-c', self.host, 'destroy', shortname]
+        args = [executable, '-c', self.host, 'destroy', self.shortname]
         proc = subprocess.Popen(args, stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,)
         out, err = proc.communicate()
         if err:
+            not_found_msg = "no domain with matching name '%s'" % self.shortname
+            if not_found_msg in err:
+                log.warn("Ignoring error during destroy: %s", err)
+                return True
             log.error("Error destroying {machine}: {msg}".format(
                 machine=self.name, msg=err))
             return False
@@ -257,4 +260,4 @@ def get_distro_from_downburst():
     except (subprocess.CalledProcessError, OSError):
         log.exception("Error calling downburst!")
         log.info('Using default values for supported os_type/os_version')
-        return default_table
\ No newline at end of file
+        return default_table