Merge ~mpontillo/maas:backport--bug-1730991--bug-1730626--2.3 into maas:2.3

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: f000fe15e99b2626f4a2b8a0f889146b77023e23
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~mpontillo/maas:backport--bug-1730991--bug-1730626--2.3
Merge into: maas:2.3
Diff against target: 227 lines (+115/-2)
6 files modified
src/maasserver/api/interfaces.py (+3/-0)
src/maasserver/forms/interface.py (+5/-0)
src/maasserver/forms/tests/test_interface.py (+4/-0)
src/maasserver/preseed_network.py (+9/-0)
src/maasserver/tests/test_preseed_network.py (+92/-1)
src/provisioningserver/utils/netplan.py (+2/-1)
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+334873@code.launchpad.net

Commit message

LP: #1730626, #1730991 - Backport bond fixes from master.

 * Only configure lacp_rate for 802.3ad bonds.
 * Add ability to configure the number of peer notifications after a bond failover event.

Backports: d0273adb02ca81784fbf56e43d0290e8c3d84d56
Backports: f0fe0c483e43bc34704be65245339aa24119547a

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

Self-review backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/interfaces.py b/src/maasserver/api/interfaces.py
2index 5e96ff4..577998d 100644
3--- a/src/maasserver/api/interfaces.py
4+++ b/src/maasserver/api/interfaces.py
5@@ -218,6 +218,9 @@ class InterfacesHandler(OperationsHandler):
6 :param bond_xmit_hash_policy: The transmit hash policy to use for
7 slave selection in balance-xor, 802.3ad, and tlb modes.
8 (Default: layer2)
9+ :param bond_num_grat_arp: The number of peer notifications (IPv4 ARP
10+ or IPv6 Neighbour Advertisements) to be issued after a failover.
11+ (Default: 1)
12
13 Supported bonding modes (bond-mode):
14 balance-rr - Transmit packets in sequential order from the first
15diff --git a/src/maasserver/forms/interface.py b/src/maasserver/forms/interface.py
16index 29bea62..d5b0dae 100644
17--- a/src/maasserver/forms/interface.py
18+++ b/src/maasserver/forms/interface.py
19@@ -422,6 +422,11 @@ class BondInterfaceForm(ChildInterfaceForm):
20
21 bond_updelay = forms.IntegerField(min_value=0, initial=0, required=False)
22
23+ # Note: we don't need a separate bond_num_unsol_na field, since (as of
24+ # Linux kernel 3.0+) it's actually an alias for the same value.
25+ bond_num_grat_arp = forms.IntegerField(
26+ min_value=0, max_value=255, initial=1, required=False)
27+
28 bond_lacp_rate = forms.ChoiceField(
29 choices=BOND_LACP_RATE_CHOICES, required=False,
30 initial=BOND_LACP_RATE_CHOICES[0][0], error_messages={
31diff --git a/src/maasserver/forms/tests/test_interface.py b/src/maasserver/forms/tests/test_interface.py
32index 15719f4..a880467 100644
33--- a/src/maasserver/forms/tests/test_interface.py
34+++ b/src/maasserver/forms/tests/test_interface.py
35@@ -789,6 +789,7 @@ class BondInterfaceFormTest(MAASServerTestCase):
36 "bond_miimon": 100,
37 "bond_downdelay": 0,
38 "bond_updelay": 0,
39+ "bond_num_grat_arp": 1,
40 "bond_lacp_rate": "fast",
41 "bond_xmit_hash_policy": "layer2",
42 }, interface.params)
43@@ -803,6 +804,7 @@ class BondInterfaceFormTest(MAASServerTestCase):
44 bond_miimon = random.randint(0, 1000)
45 bond_downdelay = random.randint(0, 1000)
46 bond_updelay = random.randint(0, 1000)
47+ bond_num_grat_arp = random.randint(0, 255)
48 bond_lacp_rate = factory.pick_choice(BOND_LACP_RATE_CHOICES)
49 bond_xmit_hash_policy = factory.pick_choice(
50 BOND_XMIT_HASH_POLICY_CHOICES)
51@@ -818,6 +820,7 @@ class BondInterfaceFormTest(MAASServerTestCase):
52 'bond_updelay': bond_updelay,
53 'bond_lacp_rate': bond_lacp_rate,
54 'bond_xmit_hash_policy': bond_xmit_hash_policy,
55+ 'bond_num_grat_arp': bond_num_grat_arp,
56 })
57 self.assertTrue(form.is_valid(), dict(form.errors))
58 interface = form.save()
59@@ -828,6 +831,7 @@ class BondInterfaceFormTest(MAASServerTestCase):
60 "bond_updelay": bond_updelay,
61 "bond_lacp_rate": bond_lacp_rate,
62 "bond_xmit_hash_policy": bond_xmit_hash_policy,
63+ "bond_num_grat_arp": bond_num_grat_arp,
64 }, interface.params)
65
66 def test__rejects_no_parents(self):
67diff --git a/src/maasserver/preseed_network.py b/src/maasserver/preseed_network.py
68index 539296d..1be72d6 100644
69--- a/src/maasserver/preseed_network.py
70+++ b/src/maasserver/preseed_network.py
71@@ -396,6 +396,15 @@ class InterfaceConfiguration:
72 # which MAAS uses to keep consistent with bridges.
73 params[key.replace("_", "-")] = (
74 _get_param_value(value))
75+ bond_mode = params.get('bond-mode')
76+ if bond_mode is not None:
77+ # Bug #1730626: lacp-rate should only be set on 802.3ad bonds.
78+ if bond_mode != "802.3ad":
79+ params.pop("bond-lacp-rate", None)
80+ # Bug #1730991: these parameters only apply to active-backup mode.
81+ if bond_mode != "active-backup":
82+ params.pop("bond-num-grat-arp", None)
83+ params.pop("bond-num-unsol-na", None)
84 return params
85
86 def _get_bridge_params(self, version=1):
87diff --git a/src/maasserver/tests/test_preseed_network.py b/src/maasserver/tests/test_preseed_network.py
88index fbbb648..8a509dc 100644
89--- a/src/maasserver/tests/test_preseed_network.py
90+++ b/src/maasserver/tests/test_preseed_network.py
91@@ -569,7 +569,7 @@ class TestNetplan(MAASServerTestCase):
92 }
93 self.expectThat(netplan, Equals(expected_netplan))
94
95- def test__bond_with_params(self):
96+ def test__non_lacp_bond_with_params(self):
97 node = factory.make_Node()
98 eth0 = factory.make_Interface(
99 node=node, name='eth0', mac_address="00:01:02:03:04:05")
100@@ -581,6 +581,7 @@ class TestNetplan(MAASServerTestCase):
101 "bond_mode": "active-backup",
102 "bond_lacp_rate": "slow",
103 "bond_xmit_hash_policy": "layer2",
104+ "bond_num_grat_arp": 3,
105 })
106 netplan = self._render_netplan_dict(node)
107 expected_netplan = {
108@@ -604,6 +605,51 @@ class TestNetplan(MAASServerTestCase):
109 'mtu': 1500,
110 'parameters': {
111 "mode": "active-backup",
112+ "transmit-hash-policy": "layer2",
113+ "gratuitous-arp": 3,
114+ },
115+ },
116+ },
117+ }
118+ }
119+ self.expectThat(netplan, Equals(expected_netplan))
120+
121+ def test__lacp_bond_with_params(self):
122+ node = factory.make_Node()
123+ eth0 = factory.make_Interface(
124+ node=node, name='eth0', mac_address="00:01:02:03:04:05")
125+ eth1 = factory.make_Interface(
126+ node=node, name='eth1', mac_address="02:01:02:03:04:05")
127+ factory.make_Interface(
128+ INTERFACE_TYPE.BOND,
129+ node=node, name='bond0', parents=[eth0, eth1], params={
130+ "bond_mode": "802.3ad",
131+ "bond_lacp_rate": "slow",
132+ "bond_xmit_hash_policy": "layer2",
133+ "bond_num_grat_arp": 3,
134+ })
135+ netplan = self._render_netplan_dict(node)
136+ expected_netplan = {
137+ 'network': {
138+ 'version': 2,
139+ 'ethernets': {
140+ 'eth0': {
141+ 'match': {'macaddress': '00:01:02:03:04:05'},
142+ 'mtu': 1500,
143+ 'set-name': 'eth0'
144+ },
145+ 'eth1': {
146+ 'match': {'macaddress': '02:01:02:03:04:05'},
147+ 'mtu': 1500,
148+ 'set-name': 'eth1'
149+ },
150+ },
151+ 'bonds': {
152+ 'bond0': {
153+ 'interfaces': ['eth0', 'eth1'],
154+ 'mtu': 1500,
155+ 'parameters': {
156+ "mode": "802.3ad",
157 "lacp-rate": "slow",
158 "transmit-hash-policy": "layer2",
159 },
160@@ -613,6 +659,51 @@ class TestNetplan(MAASServerTestCase):
161 }
162 self.expectThat(netplan, Equals(expected_netplan))
163
164+ def test__active_backup_with_legacy_parameter(self):
165+ node = factory.make_Node()
166+ eth0 = factory.make_Interface(
167+ node=node, name='eth0', mac_address="00:01:02:03:04:05")
168+ eth1 = factory.make_Interface(
169+ node=node, name='eth1', mac_address="02:01:02:03:04:05")
170+ factory.make_Interface(
171+ INTERFACE_TYPE.BOND,
172+ node=node, name='bond0', parents=[eth0, eth1], params={
173+ "bond_mode": "active-backup",
174+ "bond_lacp_rate": "slow",
175+ "bond_xmit_hash_policy": "layer2",
176+ "bond_num_unsol_na": 3,
177+ })
178+ netplan = self._render_netplan_dict(node)
179+ expected_netplan = {
180+ 'network': {
181+ 'version': 2,
182+ 'ethernets': {
183+ 'eth0': {
184+ 'match': {'macaddress': '00:01:02:03:04:05'},
185+ 'mtu': 1500,
186+ 'set-name': 'eth0'
187+ },
188+ 'eth1': {
189+ 'match': {'macaddress': '02:01:02:03:04:05'},
190+ 'mtu': 1500,
191+ 'set-name': 'eth1'
192+ },
193+ },
194+ 'bonds': {
195+ 'bond0': {
196+ 'interfaces': ['eth0', 'eth1'],
197+ 'mtu': 1500,
198+ 'parameters': {
199+ "mode": "active-backup",
200+ "transmit-hash-policy": "layer2",
201+ "gratuitous-arp": 3
202+ },
203+ },
204+ },
205+ }
206+ }
207+ self.expectThat(netplan, Equals(expected_netplan))
208+
209 def test__bridge(self):
210 node = factory.make_Node()
211 eth0 = factory.make_Interface(
212diff --git a/src/provisioningserver/utils/netplan.py b/src/provisioningserver/utils/netplan.py
213index e538079..ab88ae5 100644
214--- a/src/provisioningserver/utils/netplan.py
215+++ b/src/provisioningserver/utils/netplan.py
216@@ -55,11 +55,12 @@ ifenslave_to_netplan_bond_params = {
217 "bond-active-slave": None,
218 "bond-fail-over-mac": None,
219 "bond-master": None,
220- "bond-num-unsol-na": None, # XXX: use bond-num-grat-arp?
221 "bond-primary": None,
222 "bond-queue-id": None,
223 "bond-slaves": None,
224 "bond-use-carrier": None,
225+ # This is just an internal alias for bond-num-grat-arp.
226+ "bond-num-unsol-na": "gratuitous-arp",
227 }
228
229

Subscribers

People subscribed via source and target branches