Fix edge case + additional debugging 58/8158/7 v6.0 v6.0.4
authorAdam Israel <adam.israel@canonical.com>
Tue, 12 Nov 2019 17:37:57 +0000 (09:37 -0800)
committerAdam Israel <adam.israel@canonical.com>
Tue, 12 Nov 2019 23:28:40 +0000 (15:28 -0800)
An edge case was detected and fixed: we can't guarantee that the cloud
image used will have an updated apt cache, so run `apt-get update`
before attempting to install the iptables-persistent package.

Second, additional debug output was added to trace an error that's only
been reproduced in the rc1 LCM image published to hub.docker.com.
Building the image locally have been unable to reproduce the error.

Change-Id: I333bedab8d754102eb13b9da06ee278b6cf0d6ad
Signed-off-by: Adam Israel <adam.israel@canonical.com>
n2vc/provisioner.py

index 243d67d..00c1019 100644 (file)
@@ -73,6 +73,7 @@ fi
 
 IPTABLES_SCRIPT = """#!/bin/bash
 set -e
+DEBIAN_FRONTEND=noninteractive apt-get update
 DEBIAN_FRONTEND=noninteractive apt-get install -yqq iptables-persistent
 iptables -t nat -A OUTPUT -p tcp -d {} -j DNAT --to-destination {}
 netfilter-persistent save
@@ -317,20 +318,30 @@ class SSHProvisioner:
 
         if self._init_ubuntu_user():
             try:
+                step = "get ssh client"
                 ssh = self._get_ssh_client()
 
+                step = "detect hardware and os"
                 hw = self._detect_hardware_and_os(ssh)
+
+                step = "series"
                 params.series = hw['series']
+
+                step = "instance_id"
                 params.instance_id = "manual:{}".format(self.host)
+
+                step = "nonce"
                 params.nonce = "manual:{}:{}".format(
                     self.host,
                     str(uuid.uuid4()),  # a nop for Juju w/manual machines
                 )
+                step = "hw characteristics"
                 params.hardware_characteristics = {
                     'arch': hw['arch'],
                     'mem': int(hw['mem']),
                     'cpu-cores': int(hw['cpu-cores']),
                 }
+                step = "addresses"
                 params.addresses = [{
                     'value': self.host,
                     'type': 'ipv4',
@@ -339,6 +350,9 @@ class SSHProvisioner:
 
             except paramiko.ssh_exception.AuthenticationException as e:
                 raise e
+            except Exception as e:
+                self.log.debug("Caught exception inside provision_machine step {}: {}".format(step, e))
+                raise e
             finally:
                 ssh.close()