Merge ~yadle/cloud-init:fix-ipv6-configuration into cloud-init:master

Proposed by Raphaël Enrici
Status: Work in progress
Proposed branch: ~yadle/cloud-init:fix-ipv6-configuration
Merge into: cloud-init:master
Diff against target: 66 lines (+30/-1)
2 files modified
cloudinit/net/eni.py (+2/-0)
tests/unittests/test_distros/test_netconfig.py (+28/-1)
Reviewer Review Type Date Requested Status
Ryan Harper Needs Fixing
Server Team CI bot continuous-integration Needs Fixing
Review via email: mp+362005@code.launchpad.net

Commit message

Nocloud v1 config passes static6 as the type of subnet. This patch replaces static6 by static during interfaces file generation as static6 is not a valid keyword in /etc/network/interfaces

Description of the change

nocloud v1 network-config looks like this:
version: 1
config:
    - type: physical
      name: eth0
      mac_address: b2:b8:6e:6f:58:47
      subnets:
      - type: static
        address: <ipv4 addr>
        netmask: 255.255.255.224
        gateway: <ipv4 gw addr>
      - type: static6
        address: <ipv6 addr>
        gateway: <ipv6 gw addr>
...
Without the patch this leads to that kind of file:
/etc/network/interfaces.d/50-cloud-init.cfg:
<snip>
auto eth0
iface eth0 inet static
    address <ipv4 addr>
    gateway <ipv4 gw addr>

# control-alias eth0
iface eth0 inet6 static6
    address <ipv6 addr>
    gateway <ipv6 gw addr>
<snip>
Which is not valid, at least in ubuntu xenial. With the patch we get the right entry for ipv6 configuration:
# control-alias eth0
iface eth0 inet6 static <<<---- 6 removed here
    address <ipv6 addr>
    gateway <ipv6 gw addr>

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Yes, that's a good catch. I can reproduce this and ifupdown produces this output:

/etc/network/interfaces.d/50-cloud-init.cfg:13: unknown or no method and no inherits keyword specified
/etc/network/interfaces.d/50-cloud-init.cfg:13: unknown or no method and no inherits keyword specified
/etc/network/interfaces.d/50-cloud-init.cfg:13: unknown or no method and no inherits keyword specified

And removing the '6' from static resolves it.

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

Let's test that path, this is an update to an existing unittest to validate the 'static6' eni path.

http://paste.ubuntu.com/p/yP5fTDR49G/

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

Hi Raphael! It looks like Ryan left you with a suggested change to this branch; are you interested in applying that change and refreshing your branch against master?

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

Hi Raphael, I've marked this branch Work In Progress. Once you've applied the test-path I provided in the commit above, please push and change the state of this merge to Needs Review.

Revision history for this message
Raphaël Enrici (yadle) wrote :

Hey,
sorry for the delay, I'll work on this in the next days.
Thanks,
Raphaël

On Mon, Apr 8, 2019 at 8:17 PM Ryan Harper <email address hidden> wrote:
>
> Hi Raphael, I've marked this branch Work In Progress. Once you've applied the test-path I provided in the commit above, please push and change the state of this merge to Needs Review.
> --
> https://code.launchpad.net/~yadle/cloud-init/+git/cloud-init/+merge/362005
> You are the owner of ~yadle/cloud-init:fix-ipv6-configuration.

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

Thanks for updating the branch. LGTM.

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

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.ubuntu.com/server/job/cloud-init-autoland-test/243/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.ubuntu.com/server/job/cloud-init-autoland-test/257/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:297279d2251d0dbcd0c64f6568d07db28e196af3
https://jenkins.ubuntu.com/server/job/cloud-init-ci/783/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

This needs sorting out of the CI test failures on RedHat and OpenSuse distro variants. I'll look into that since I provided the unittest.

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

Looks like the sysconfig renderer needs to accept 'static6' as well. This should fix this:

diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index be5dede..686cd67 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -350,7 +350,7 @@ class Renderer(renderer.Renderer):
                 iface_cfg['DHCPV6C'] = True
             elif subnet_type in ['dhcp4', 'dhcp']:
                 iface_cfg['BOOTPROTO'] = 'dhcp'
- elif subnet_type == 'static':
+ elif subnet_type.startswith('static'):
                 # grep BOOTPROTO sysconfig.txt -A2 | head -3
                 # BOOTPROTO=none|bootp|dhcp
                 # 'bootp' or 'dhcp' cause a DHCP client
@@ -394,7 +394,7 @@ class Renderer(renderer.Renderer):
                 if has_default_route and iface_cfg['BOOTPROTO'] != 'none':
                     iface_cfg['DHCLIENT_SET_DEFAULT_ROUTE'] = False
                 continue
- elif subnet_type == 'static':
+ elif subnet_type.startswith('static'):
                 if subnet_is_ipv6(subnet):
                     ipv6_index = ipv6_index + 1
                     ipv6_cidr = "%s/%s" % (subnet['address'], subnet['prefix'])

review: Needs Fixing

Unmerged commits

297279d... by Raphaël Enrici

Adds test for ipv6 network/interfaces generation. (Patch Author: Ryan Harper <email address hidden>)

13c0339... by Raphaël Enrici

Replaces static6 by static as it is not a valid keyword in /etc/network/interfaces

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
2index b129bb6..b4b232c 100644
3--- a/cloudinit/net/eni.py
4+++ b/cloudinit/net/eni.py
5@@ -413,6 +413,8 @@ class Renderer(renderer.Renderer):
6 iface['inet'] = subnet_inet
7 if subnet['type'].startswith('dhcp'):
8 iface['mode'] = 'dhcp'
9+ if subnet['type'].startswith('static6'):
10+ iface['mode'] = 'static'
11
12 # do not emit multiple 'auto $IFACE' lines as older (precise)
13 # ifupdown complains
14diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
15index c3c0c8c..03bbbc8 100644
16--- a/tests/unittests/test_distros/test_netconfig.py
17+++ b/tests/unittests/test_distros/test_netconfig.py
18@@ -109,13 +109,31 @@ auto eth1
19 iface eth1 inet dhcp
20 """
21
22+V1_NET_CFG_IPV6_OUTPUT = """\
23+# This file is generated from information provided by
24+# the datasource. Changes to it will not persist across an instance.
25+# To disable cloud-init's network configuration capabilities, write a file
26+# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
27+# network: {config: disabled}
28+auto lo
29+iface lo inet loopback
30+
31+auto eth0
32+iface eth0 inet6 static
33+ address 2607:f0d0:1002:0011::2/64
34+ gateway 2607:f0d0:1002:0011::1
35+
36+auto eth1
37+iface eth1 inet dhcp
38+"""
39+
40 V1_NET_CFG_IPV6 = {'config': [{'name': 'eth0',
41 'subnets': [{'address':
42 '2607:f0d0:1002:0011::2',
43 'gateway':
44 '2607:f0d0:1002:0011::1',
45 'netmask': '64',
46- 'type': 'static'}],
47+ 'type': 'static6'}],
48 'type': 'physical'},
49 {'name': 'eth1',
50 'subnets': [{'control': 'auto',
51@@ -376,6 +394,15 @@ class TestNetCfgDistroUbuntuEni(TestNetCfgDistroBase):
52 V1_NET_CFG,
53 expected_cfgs=expected_cfgs.copy())
54
55+ def test_apply_network_config_ipv6_ub(self):
56+ expected_cfgs = {
57+ self.eni_path(): V1_NET_CFG_IPV6_OUTPUT
58+ }
59+ self._apply_and_verify_eni(self.distro.apply_network_config,
60+ V1_NET_CFG_IPV6,
61+ expected_cfgs=expected_cfgs.copy())
62+
63+
64
65 class TestNetCfgDistroUbuntuNetplan(TestNetCfgDistroBase):
66 def setUp(self):

Subscribers

People subscribed via source and target branches