Merge ~raharper/cloud-init:fix/add-netplan-fixed-grat-arp-spelling into cloud-init:master

Proposed by Ryan Harper
Status: Merged
Approved by: Chad Smith
Approved revision: 552426196d3b74791597b02284d15a5a54fedf29
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/cloud-init:fix/add-netplan-fixed-grat-arp-spelling
Merge into: cloud-init:master
Diff against target: 82 lines (+54/-0)
2 files modified
cloudinit/net/network_state.py (+8/-0)
tests/unittests/test_net.py (+46/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Chad Smith Approve
Dan Watkins Approve
Review via email: mp+366935@code.launchpad.net

Commit message

netplan: update netplan key mappings for gratuitous-arp

Previous versions of netplan included a misspelling for the
bond parameter around gratuitous-arp. This has been fixed and released
and cloud-init needs to accept both values. This branch fixes the
key that will be rendered and transforms the previous misspelling
when capturing network_state.

LP: #1827238

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:67222ba81ed350da08cec2c3390d66040504da3a
https://jenkins.ubuntu.com/server/job/cloud-init-ci/703/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/703/rebuild

review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) wrote :

Do we need to handle older versions of netplan that _don't_ understand the new key?

Revision history for this message
Dan Watkins (oddbloke) :
Revision history for this message
Dan Watkins (oddbloke) wrote :

This looks good to me, assuming the answer to my above question is that we don't need to support older versions of netplan.

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

I need change this fix. On Xenial, it's not fixed to support both, so it only would accept the current value. I don't know if there are plans to

Since newer netplan supports both, but older only the misspelling, at least for now; I think we need to always write the misspelling until we have a way to determine whether it's safe to render the correct spelling version.

I'm aware of two images that use netplan, UbuntuCore16 and Rackspace Ubuntu images.

Let me refactor how we can accept either in the input config, but for now only render the mispelling; I think that's the safest at this point.

0ea9421... by Ryan Harper

netplan: accept the correctly spelled grat key, but write misspelling for compact reasons

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:0ea9421d31bff1b39e87cabeb0e5073122bd366e
https://jenkins.ubuntu.com/server/job/cloud-init-ci/704/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/704/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Minor inline suggestions, then +1 from me. Once netplan instruments support for the correct spelling of gratuitous-arp in xenial, then we can cross the bridge of removing this misspelling map.

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

Thanks for the review

5524261... by Ryan Harper

Update comment to reference original bug, note release, improve code per Chad.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:552426196d3b74791597b02284d15a5a54fedf29
https://jenkins.ubuntu.com/server/job/cloud-init-ci/711/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/711/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
2index 4d19f56..3702130 100644
3--- a/cloudinit/net/network_state.py
4+++ b/cloudinit/net/network_state.py
5@@ -707,6 +707,14 @@ class NetworkStateInterpreter(object):
6 item_params = dict((key, value) for (key, value) in
7 item_cfg.items() if key not in
8 NETWORK_V2_KEY_FILTER)
9+ # we accept the fixed spelling, but write the old for compatability
10+ # Xenial does not have an updated netplan which supports the
11+ # correct spelling. LP: #1756701
12+ params = item_params['parameters']
13+ grat_value = params.pop('gratuitous-arp', None)
14+ if grat_value:
15+ params['gratuitious-arp'] = grat_value
16+
17 v1_cmd = {
18 'type': cmd_type,
19 'name': item_name,
20diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
21index e85e964..b936bc9 100644
22--- a/tests/unittests/test_net.py
23+++ b/tests/unittests/test_net.py
24@@ -407,6 +407,37 @@ network:
25 - maas
26 """
27
28+NETPLAN_BOND_GRAT_ARP = """
29+network:
30+ bonds:
31+ bond0:
32+ interfaces:
33+ - ens3
34+ macaddress: 68:05:ca:64:d3:6c
35+ mtu: 9000
36+ parameters:
37+ gratuitious-arp: 1
38+ bond1:
39+ interfaces:
40+ - ens4
41+ macaddress: 68:05:ca:64:d3:6d
42+ mtu: 9000
43+ parameters:
44+ gratuitous-arp: 2
45+ ethernets:
46+ ens3:
47+ dhcp4: false
48+ dhcp6: false
49+ match:
50+ macaddress: 52:54:00:ab:cd:ef
51+ ens4:
52+ dhcp4: false
53+ dhcp6: false
54+ match:
55+ macaddress: 52:54:00:11:22:ff
56+ version: 2
57+"""
58+
59 NETPLAN_DHCP_FALSE = """
60 version: 2
61 ethernets:
62@@ -3589,6 +3620,21 @@ class TestNetplanRoundTrip(CiTestCase):
63 entry['expected_netplan'].splitlines(),
64 files['/etc/netplan/50-cloud-init.yaml'].splitlines())
65
66+ def test_render_output_supports_both_grat_arp_spelling(self):
67+ entry = {
68+ 'yaml': NETPLAN_BOND_GRAT_ARP,
69+ 'expected_netplan': NETPLAN_BOND_GRAT_ARP.replace('gratuitous',
70+ 'gratuitious'),
71+ }
72+ network_config = yaml.load(entry['yaml']).get('network')
73+ files = self._render_and_read(network_config=network_config)
74+ print(entry['expected_netplan'])
75+ print('-- expected ^ | v rendered --')
76+ print(files['/etc/netplan/50-cloud-init.yaml'])
77+ self.assertEqual(
78+ entry['expected_netplan'].splitlines(),
79+ files['/etc/netplan/50-cloud-init.yaml'].splitlines())
80+
81
82 class TestEniRoundTrip(CiTestCase):
83

Subscribers

People subscribed via source and target branches