Merge ~mpontillo/maas:dont-create-fabrics-for-disabled-interfaces into maas:master

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: 811966c16533b7290f4d7db5dd39ec6f2cb215cc
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~mpontillo/maas:dont-create-fabrics-for-disabled-interfaces
Merge into: maas:master
Diff against target: 94 lines (+46/-7)
2 files modified
src/maasserver/models/node.py (+18/-7)
src/maasserver/models/tests/test_node.py (+28/-0)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+327688@code.launchpad.net

Commit message

Ensure that disabled interfaces do not create new fabrics.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

LANDING
-b dont-create-fabrics-for-disabled-interfaces lp:~mpontillo/maas into -b master lp:~maas-committers/maas

STATUS: FAILED BUILD
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/118/console

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Looks like some type of random failure with postgresql.

http://paste.ubuntu.com/25124643/

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Let's file a bug for that :)

On Wed, Jul 19, 2017 at 12:10 PM Mike Pontillo <email address hidden>
wrote:

> Looks like some type of random failure with postgresql.
>
> http://paste.ubuntu.com/25124643/
> --
> https://code.launchpad.net/~mpontillo/maas/+git/maas/+merge/327688
> Your team MAAS Committers is subscribed to branch maas:master.
>
--
Andres Rodriguez
Engineering Manager, MAAS
Canonical USA, Inc.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

I would file a bug, but it would be Incomplete. =(

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
index 0b92fb1..d27a111 100644
--- a/src/maasserver/models/node.py
+++ b/src/maasserver/models/node.py
@@ -4148,9 +4148,16 @@ class Controller(Node):
4148 "name": name,4148 "name": name,
4149 "enabled": is_enabled,4149 "enabled": is_enabled,
4150 })4150 })
4151 if create_fabrics and interface.vlan is None:4151 # Don't update the VLAN unless:
4152 new_vlan = self._update_vlan_for_interface(4152 # (1) We're at the phase where we're creating fabrics.
4153 interface, config, new_vlan)4153 # (that is, beaconing has already completed)
4154 # (2) The interface's VLAN wasn't previously known.
4155 # (3) The interface is administratively enabled.
4156 if create_fabrics and interface.vlan is None and is_enabled:
4157 new_vlan = self._guess_vlan_for_interface(interface, config)
4158 if new_vlan is not None:
4159 interface.vlan = new_vlan
4160 update_fields.add('vlan')
4154 if not created:4161 if not created:
4155 if interface.node.id != self.id:4162 if interface.node.id != self.id:
4156 # MAC address was on a different node. We need to move4163 # MAC address was on a different node. We need to move
@@ -4187,14 +4194,20 @@ class Controller(Node):
4187 # a link re-assigned the VLAN this interface is connected to.4194 # a link re-assigned the VLAN this interface is connected to.
4188 new_vlan.fabric.delete()4195 new_vlan.fabric.delete()
41894196
4190 def _update_vlan_for_interface(self, interface, config, new_vlan):4197 def _guess_vlan_for_interface(self, interface, config):
4191 # Make sure that the VLAN on the interface is correct. When4198 # Make sure that the VLAN on the interface is correct. When
4192 # links exists on this interface we place it into the correct4199 # links exists on this interface we place it into the correct
4193 # VLAN. If it cannot be determined and its a new interface it4200 # VLAN. If it cannot be determined and its a new interface it
4194 # gets placed on its own fabric.4201 # gets placed on its own fabric.
4202 new_vlan = None
4195 connected_to_subnets = self._get_connected_subnets(4203 connected_to_subnets = self._get_connected_subnets(
4196 config["links"])4204 config["links"])
4197 if len(connected_to_subnets) == 0:4205 if len(connected_to_subnets) > 0:
4206 for subnet in connected_to_subnets:
4207 new_vlan = subnet.vlan
4208 if new_vlan is not None:
4209 break
4210 if new_vlan is None:
4198 # If the default VLAN on the default fabric has no interfaces4211 # If the default VLAN on the default fabric has no interfaces
4199 # associated with it, the first interface will be placed there4212 # associated with it, the first interface will be placed there
4200 # (rather than creating a new fabric).4213 # (rather than creating a new fabric).
@@ -4206,8 +4219,6 @@ class Controller(Node):
4206 else:4219 else:
4207 new_fabric = Fabric.objects.create()4220 new_fabric = Fabric.objects.create()
4208 new_vlan = new_fabric.get_default_vlan()4221 new_vlan = new_fabric.get_default_vlan()
4209 interface.vlan = new_vlan
4210 interface.save()
4211 return new_vlan4222 return new_vlan
42124223
4213 def _get_or_create_vlan_interface(self, name, vlan, parent):4224 def _get_or_create_vlan_interface(self, name, vlan, parent):
diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
index 60d82db..88ad200 100644
--- a/src/maasserver/models/tests/test_node.py
+++ b/src/maasserver/models/tests/test_node.py
@@ -9213,6 +9213,34 @@ class TestUpdateInterfaces(MAASServerTestCase):
9213 self.assertIsNotNone(eth0)9213 self.assertIsNotNone(eth0)
9214 self.assertIsNotNone(br0)9214 self.assertIsNotNone(br0)
92159215
9216 def test_disabled_interfaces_do_not_create_fabrics(self):
9217 controller = self.create_empty_controller()
9218 interfaces = {
9219 'eth0': {
9220 'enabled': True,
9221 'links': [],
9222 'mac_address': '52:54:00:77:15:e3',
9223 'parents': [],
9224 'source': 'ipaddr',
9225 'type': 'physical'
9226 },
9227 'eth1': {
9228 'enabled': False,
9229 'links': [],
9230 'mac_address': '52:54:00:77:15:e4',
9231 'parents': [],
9232 'source': 'ipaddr',
9233 'type': 'physical'
9234 },
9235 }
9236 self.update_interfaces(controller, interfaces)
9237 eth0 = get_one(
9238 PhysicalInterface.objects.filter(node=controller, name='eth0'))
9239 eth1 = get_one(
9240 PhysicalInterface.objects.filter(node=controller, name='eth1'))
9241 self.assertIsNotNone(eth0.vlan)
9242 self.assertIsNone(eth1.vlan)
9243
92169244
9217class TestRackControllerRefresh(MAASTransactionServerTestCase):9245class TestRackControllerRefresh(MAASTransactionServerTestCase):
92189246

Subscribers

People subscribed via source and target branches