From: Adam Israel Date: Tue, 12 Nov 2019 17:37:57 +0000 (-0800) Subject: Fix edge case + additional debugging X-Git-Tag: v6.0.4^0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=13a999650c017ed1fa936860378ddd77eb8b12ca;p=osm%2FN2VC.git Fix edge case + additional debugging 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 --- diff --git a/n2vc/provisioner.py b/n2vc/provisioner.py index 243d67d..00c1019 100644 --- a/n2vc/provisioner.py +++ b/n2vc/provisioner.py @@ -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()