Merge lp:~mpontillo/maas/fix-parent-mtu-less-than-child--bug-1662948 into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 5863
Proposed branch: lp:~mpontillo/maas/fix-parent-mtu-less-than-child--bug-1662948
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 159 lines (+81/-43)
2 files modified
src/maasserver/models/interface.py (+7/-0)
src/maasserver/models/tests/test_interface.py (+74/-43)
To merge this branch: bzr merge lp:~mpontillo/maas/fix-parent-mtu-less-than-child--bug-1662948
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+321125@code.launchpad.net

Commit message

Consider child interface MTUs when deciding a parent interface's effective MTU.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Note: I moved all the MTU-related test cases into their own suite, InterfaceMTUTest, so that future developers working with MTU-related issues have an easy way to run all the interface-model-related tests.

Revision history for this message
Lee Trager (ltrager) wrote :

Should src/maasserver/forms/interface.py be updated to raise a validation error when this occurs, or should the parent MUTS always automatically supersede the child?

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

I think adding a ValidationError here would just make it hard on the user, since there are so many different ways to determine the effective MTU.

According to the bug reports on this issue (there were a couple duplicates, too), if you try to deploy a node where the parent MTU is less than its children, the deployment will fail and the interfaces will not come online.

Revision history for this message
Lee Trager (ltrager) wrote :

Sounds resonable.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (32.7 KiB)

The attempt to merge lp:~mpontillo/maas/fix-parent-mtu-less-than-child--bug-1662948 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Sources [237 kB]
Get:6 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [499 kB]
Get:7 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [200 kB]
Get:8 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [448 kB]
Fetched 1,690 kB in 0s (2,249 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is al...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/interface.py'
2--- src/maasserver/models/interface.py 2017-03-24 22:52:14 +0000
3+++ src/maasserver/models/interface.py 2017-03-28 03:35:50 +0000
4@@ -597,6 +597,13 @@
5 # MTU set and it is disconnected.
6 from maasserver.models.vlan import DEFAULT_MTU
7 mtu = DEFAULT_MTU
8+ children = self.get_successors()
9+ # Check if any child interface has a greater MTU. It is an invalid
10+ # configuration for the parent MTU to be smaller. (LP: #1662948)
11+ for child in children:
12+ child_mtu = child.get_effective_mtu()
13+ if mtu < child_mtu:
14+ mtu = child_mtu
15 return mtu
16
17 def get_links(self):
18
19=== modified file 'src/maasserver/models/tests/test_interface.py'
20--- src/maasserver/models/tests/test_interface.py 2017-03-24 22:57:02 +0000
21+++ src/maasserver/models/tests/test_interface.py 2017-03-28 03:35:50 +0000
22@@ -913,27 +913,6 @@
23 alloc_type=IPADDRESS_TYPE.AUTO, interface=nic1)
24 self.assertTrue(nic1.is_configured())
25
26- def test_get_effective_mtu_returns_interface_mtu(self):
27- nic1 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
28- nic_mtu = random.randint(552, 4096)
29- nic1.params = {
30- "mtu": nic_mtu
31- }
32- nic1.save()
33- self.assertEqual(nic_mtu, nic1.get_effective_mtu())
34-
35- def test_get_effective_mtu_returns_vlan_mtu(self):
36- nic1 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
37- vlan_mtu = random.randint(552, 4096)
38- nic1.vlan.mtu = vlan_mtu
39- nic1.vlan.save()
40- self.assertEqual(vlan_mtu, nic1.get_effective_mtu())
41-
42- def test_get_effective_mtu_returns_default_mtu(self):
43- nic1 = factory.make_Interface(
44- INTERFACE_TYPE.PHYSICAL, disconnected=True)
45- self.assertEqual(DEFAULT_MTU, nic1.get_effective_mtu())
46-
47 def test_get_links_returns_links_for_each_type(self):
48 interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
49 links = []
50@@ -1372,6 +1351,80 @@
51 self.assertFalse(reload_object(interface).enabled)
52
53
54+class InterfaceMTUTest(MAASServerTestCase):
55+
56+ def test_get_effective_mtu_returns_default_mtu(self):
57+ nic1 = factory.make_Interface(
58+ INTERFACE_TYPE.PHYSICAL, disconnected=True)
59+ self.assertEqual(DEFAULT_MTU, nic1.get_effective_mtu())
60+
61+ def test_get_effective_mtu_returns_interface_mtu(self):
62+ nic1 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
63+ nic_mtu = random.randint(552, 9100)
64+ nic1.params = {
65+ "mtu": nic_mtu
66+ }
67+ nic1.save()
68+ self.assertEqual(nic_mtu, nic1.get_effective_mtu())
69+
70+ def test_get_effective_mtu_returns_vlan_mtu(self):
71+ nic1 = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
72+ vlan_mtu = random.randint(552, 9100)
73+ nic1.vlan.mtu = vlan_mtu
74+ nic1.vlan.save()
75+ self.assertEqual(vlan_mtu, nic1.get_effective_mtu())
76+
77+ def test_get_effective_mtu_considers_jumbo_vlan_children(self):
78+ fabric = factory.make_Fabric()
79+ vlan = factory.make_VLAN(fabric=fabric)
80+ eth0 = factory.make_Interface(
81+ INTERFACE_TYPE.PHYSICAL, vlan=fabric.get_default_vlan())
82+ eth0_vlan = factory.make_Interface(
83+ iftype=INTERFACE_TYPE.VLAN, vlan=vlan, parents=[eth0])
84+ vlan_mtu = random.randint(DEFAULT_MTU + 1, 9100)
85+ eth0_vlan.vlan.mtu = vlan_mtu
86+ eth0_vlan.vlan.save()
87+ self.assertEqual(vlan_mtu, eth0.get_effective_mtu())
88+
89+ def test_get_effective_mtu_returns_highest_vlan_mtu(self):
90+ fabric = factory.make_Fabric()
91+ vlan1 = factory.make_VLAN(fabric=fabric)
92+ vlan2 = factory.make_VLAN(fabric=fabric)
93+ eth0 = factory.make_Interface(
94+ INTERFACE_TYPE.PHYSICAL, vlan=fabric.get_default_vlan())
95+ eth0_vlan1 = factory.make_Interface(
96+ iftype=INTERFACE_TYPE.VLAN, vlan=vlan1, parents=[eth0])
97+ eth0_vlan2 = factory.make_Interface(
98+ iftype=INTERFACE_TYPE.VLAN, vlan=vlan2, parents=[eth0])
99+ eth0_vlan1.vlan.mtu = random.randint(1000, 1999)
100+ eth0_vlan1.vlan.save()
101+ eth0_vlan2.vlan.mtu = random.randint(2000, 2999)
102+ eth0_vlan2.vlan.save()
103+ self.assertEqual(eth0_vlan2.vlan.mtu, eth0.get_effective_mtu())
104+
105+ def test__creates_acquired_bridge_copies_mtu(self):
106+ mtu = random.randint(600, 9100)
107+ parent = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
108+ parent.params = {'mtu': mtu}
109+ parent.save()
110+ bridge = parent.create_acquired_bridge()
111+ self.assertThat(bridge, MatchesStructure(
112+ name=Equals("br-%s" % parent.get_name()),
113+ mac_address=Equals(parent.mac_address),
114+ node=Equals(parent.node),
115+ vlan=Equals(parent.vlan),
116+ enabled=Equals(True),
117+ acquired=Equals(True),
118+ params=MatchesDict({
119+ "bridge_stp": Equals(False),
120+ "bridge_fd": Equals(15),
121+ "mtu": Equals(mtu),
122+ })
123+ ))
124+ self.assertEquals(
125+ [parent.id], [p.id for p in bridge.parents.all()])
126+
127+
128 class VLANInterfaceTest(MAASServerTestCase):
129
130 def test_vlan_has_generated_name(self):
131@@ -2968,28 +3021,6 @@
132 self.assertEquals(
133 [parent.id], [p.id for p in bridge.parents.all()])
134
135- def test__creates_acquired_bridge_copies_mtu(self):
136- mtu = random.randint(600, 1000)
137- parent = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
138- parent.params = {'mtu': mtu}
139- parent.save()
140- bridge = parent.create_acquired_bridge()
141- self.assertThat(bridge, MatchesStructure(
142- name=Equals("br-%s" % parent.get_name()),
143- mac_address=Equals(parent.mac_address),
144- node=Equals(parent.node),
145- vlan=Equals(parent.vlan),
146- enabled=Equals(True),
147- acquired=Equals(True),
148- params=MatchesDict({
149- "bridge_stp": Equals(False),
150- "bridge_fd": Equals(15),
151- "mtu": Equals(mtu),
152- })
153- ))
154- self.assertEquals(
155- [parent.id], [p.id for p in bridge.parents.all()])
156-
157 def test__creates_acquired_bridge_moves_links_from_parent_to_bridge(self):
158 parent = factory.make_Interface(INTERFACE_TYPE.PHYSICAL)
159 auto_ip = factory.make_StaticIPAddress(