Address issues found in lab deploys
- Don't include route to source subnet for routedomains Closes #76 - Wrap adding network address ranges in MaaS driver in a try block and log failures without fatally exiting function Closes #82 - Wrap action.start() in a try block and mark initiating task failed on exception (with detail status msg) Closes #81 Change-Id: I29aea0e91b8fb5619b3349e99526afbc737d540e
This commit is contained in:
parent
cd4333c4d8
commit
992359fa21
@ -302,8 +302,11 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
self.task.add_status_msg(
|
||||
msg=msg, error=False, ctx=l.name, ctx_type='network_link')
|
||||
vlan = vlan_list.singleton({'vid': 0})
|
||||
vlan.mtu = l.mtu
|
||||
vlan.update()
|
||||
if vlan:
|
||||
vlan.mtu = l.mtu
|
||||
vlan.update()
|
||||
else:
|
||||
self.logger.warning("Unable to find native VLAN on fabric %s." % link_fabric.resource_id)
|
||||
|
||||
# Now that we have the fabrics sorted out, check
|
||||
# that VLAN tags and subnet attributes are correct
|
||||
@ -455,9 +458,19 @@ class CreateNetworkTemplate(BaseMaasAction):
|
||||
dhcp_on = False
|
||||
|
||||
for r in n.ranges:
|
||||
subnet.add_address_range(r)
|
||||
if r.get('type', None) == 'dhcp':
|
||||
dhcp_on = True
|
||||
try:
|
||||
subnet.add_address_range(r)
|
||||
if r.get('type', None) == 'dhcp':
|
||||
dhcp_on = True
|
||||
except Exception as e:
|
||||
msg = "Error adding range to network %s: %s" % (
|
||||
n.name, str(r))
|
||||
self.logger.error(msg, exc_info=e)
|
||||
self.task.add_status_msg(
|
||||
msg=msg,
|
||||
error=True,
|
||||
ctx=n.name,
|
||||
ctx_type='network')
|
||||
|
||||
vlan_list = maas_vlan.Vlans(
|
||||
self.maas_client, fabric_id=subnet.fabric)
|
||||
|
@ -193,15 +193,26 @@ class MaasNodeDriver(NodeDriver):
|
||||
task.bubble_results()
|
||||
task.align_result()
|
||||
else:
|
||||
maas_client = MaasRequestFactory(
|
||||
config.config_mgr.conf.maasdriver.maas_api_url,
|
||||
config.config_mgr.conf.maasdriver.maas_api_key)
|
||||
action = self.action_class_map.get(task.action, None)(
|
||||
task,
|
||||
self.orchestrator,
|
||||
self.state_manager,
|
||||
maas_client=maas_client)
|
||||
action.start()
|
||||
try:
|
||||
maas_client = MaasRequestFactory(
|
||||
config.config_mgr.conf.maasdriver.maas_api_url,
|
||||
config.config_mgr.conf.maasdriver.maas_api_key)
|
||||
action = self.action_class_map.get(task.action, None)(
|
||||
task,
|
||||
self.orchestrator,
|
||||
self.state_manager,
|
||||
maas_client=maas_client)
|
||||
action.start()
|
||||
except Exception as e:
|
||||
msg = "Subtask for action %s raised unexpected exceptions" % task.action
|
||||
self.logger.error(
|
||||
msg, exc_info=e.exception())
|
||||
task.add_status_msg(
|
||||
msg,
|
||||
error=True,
|
||||
ctx=str(task.get_id()),
|
||||
ctx_type='task')
|
||||
task.failure()
|
||||
|
||||
task.set_status(hd_fields.TaskStatus.Complete)
|
||||
task.save()
|
||||
|
@ -598,5 +598,6 @@ class Orchestrator(object):
|
||||
break
|
||||
if gw is not None and metric is not None:
|
||||
for cidr in rd_cidrs:
|
||||
n.routes.append(
|
||||
dict(subnet=cidr, gateway=gw, metric=metric))
|
||||
if cidr != n.cidr:
|
||||
n.routes.append(
|
||||
dict(subnet=cidr, gateway=gw, metric=metric))
|
||||
|
@ -44,10 +44,35 @@ class TestRouteDomains(object):
|
||||
if 'subnet' in r and r.get('subnet') is not None:
|
||||
route_cidrs.append(r.get('subnet'))
|
||||
|
||||
assert len(route_cidrs) == 3
|
||||
assert len(route_cidrs) == 2
|
||||
|
||||
assert '172.16.1.0/24' in route_cidrs
|
||||
|
||||
assert '172.16.2.0/24' in route_cidrs
|
||||
|
||||
assert '172.16.3.0/24' in route_cidrs
|
||||
def test_routedomain_omit_source_subnet(self, input_files, setup):
|
||||
input_file = input_files.join("deckhand_routedomain.yaml")
|
||||
|
||||
design_state = DrydockState()
|
||||
design_ref = "file://%s" % str(input_file)
|
||||
|
||||
ingester = Ingester()
|
||||
ingester.enable_plugin(
|
||||
'drydock_provisioner.ingester.plugins.deckhand.DeckhandIngester')
|
||||
|
||||
orchestrator = Orchestrator(
|
||||
state_manager=design_state, ingester=ingester)
|
||||
|
||||
design_status, design_data = orchestrator.get_effective_site(
|
||||
design_ref)
|
||||
|
||||
assert design_status.status == hd_fields.ActionResult.Success
|
||||
|
||||
net_rack3 = design_data.get_network('storage_rack3')
|
||||
|
||||
route_cidrs = list()
|
||||
for r in net_rack3.routes:
|
||||
if 'subnet' in r and r.get('subnet') is not None:
|
||||
route_cidrs.append(r.get('subnet'))
|
||||
|
||||
assert '172.16.3.0/24' not in route_cidrs
|
||||
|
Loading…
x
Reference in New Issue
Block a user