From 7fe70bd2b30d19e433d67228d1ae4e9b328f809b Mon Sep 17 00:00:00 2001 From: Scott Hussey Date: Thu, 8 Mar 2018 16:21:33 -0600 Subject: [PATCH] [Fix] Invalid network config silently fails - Gracefully handle when a node interface is attached to a network that does not exist in MaaS. Change-Id: I454016dc74a5d78bcd271ca35fda774dccd316a2 --- .../drivers/node/maasdriver/actions/node.py | 15 +++++++++++++-- .../drivers/node/maasdriver/models/interface.py | 7 ++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drydock_provisioner/drivers/node/maasdriver/actions/node.py b/drydock_provisioner/drivers/node/maasdriver/actions/node.py index 4d7b5feb..9434cd62 100644 --- a/drydock_provisioner/drivers/node/maasdriver/actions/node.py +++ b/drydock_provisioner/drivers/node/maasdriver/actions/node.py @@ -1126,8 +1126,19 @@ class ApplyNodeNetworking(BaseMaasAction): % (dd_net.vlan_id, n.name, i.device_name)) - link_iface = machine.interfaces.create_vlan( - **vlan_options) + try: + link_iface = machine.interfaces.create_vlan( + **vlan_options) + except errors.DriverError as ex: + msg = "Error creating interface: %s" % str(ex) + self.logger.info(msg) + self.task.add_status_msg( + msg=msg, + error=True, + ctx=n.name, + ctx_type='node') + self.task.failure(focus=n.name) + continue link_options = {} link_options[ diff --git a/drydock_provisioner/drivers/node/maasdriver/models/interface.py b/drydock_provisioner/drivers/node/maasdriver/models/interface.py index 6605ef5d..da7fd117 100644 --- a/drydock_provisioner/drivers/node/maasdriver/models/interface.py +++ b/drydock_provisioner/drivers/node/maasdriver/models/interface.py @@ -319,9 +319,10 @@ class Interfaces(model_base.ResourceCollectionBase): vlan = vlans.singleton({'vid': vlan_tag}) if vlan is None: - self.logger.error( - "Cannot locate VLAN %s on fabric %s to attach interface" % - (vlan_tag, parent_iface.fabric_id)) + msg = ("Cannot locate VLAN %s on fabric %s to attach interface" % + (vlan_tag, parent_iface.fabric_id)) + self.logger.warning(msg) + raise errors.DriverError(msg) exists = self.singleton({'vlan': vlan.resource_id})