canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.88k stars 859 forks source link

cloudinit/net/sysconfig.py write incorrect config for dhcp-stateless openstack subnets #3462

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1847517

Launchpad details
affected_projects = []
assignee = harald-jensas
assignee_name = Harald Jensås
date_closed = 2019-12-19T22:59:53.749510+00:00
date_created = 2019-10-09T18:44:18.041501+00:00
date_fix_committed = 2019-10-16T15:30:33.367558+00:00
date_fix_released = 2019-12-19T22:59:53.749510+00:00
id = 1847517
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1847517
milestone = None
owner = harald-jensas
owner_name = Harald Jensås
private = False
status = fix_released
submitter = harald-jensas
submitter_name = Harald Jensås
tags = ['rhel']
duplicates = []

Launchpad user Harald Jensås(harald-jensas) wrote on 2019-10-09T18:44:18.041501+00:00

$ openstack subnet show 48c8407b-7ef3-4047-82dd-ca6d671c2162 -c ipv6_address_mode -c ipv6_ra_mode
+-------------------+------------------+ | Field | Value | +-------------------+------------------+ | ipv6_address_mode | dhcpv6-stateless | | ipv6_ra_mode | dhcpv6-stateless | +-------------------+------------------+

File: openstack/latest/network_data.json

{ "services": [ { "type": "dns", "address": "fd12:3456:789a:1::1" } ], "networks": [ { "network_id": "cf79eea0-6196-45a0-b9f8-ff9dd95eaab3", "type": "ipv6_dhcpv6-stateless", "services": [ { "type": "dns", "address": "fd12:3456:789a:1::1" } ], "netmask": "ffff:ffff:ffff:ffff::", "link": "tap5910c6cc-2d", "routes": [ { "netmask": "::", "network": "::", "gateway": "fd12:3456:789a:1::fffe" } ], "ip_address": "fd12:3456:789a:1:f816:3eff:fee2:3aa3", "id": "network0" } ], "links": [ { "vif_id": "5910c6cc-2d6e-4a44-bf05-2accdefd0316", "type": "phy", "ethernet_mac_address": "fa:16:3e:73:0d:96", "id": "tap5910c6cc-2d", "mtu": 1450 } ] }

Actual result

The network config forces the client to try dhcpv6, not stateless e.g slaac. This fails when there is no DHCPv6 configured, or DHCPv6 is only configured to provide advanced options such a bootfile-url etc.

Created by cloud-init on instance boot automatically, do not edit.

# BOOTPROTO=none DEFROUTE=yes DEVICE=eth0 DHCPV6C=yes HWADDR=fa:16:3e:73:0d:96 IPV6INIT=yes IPV6_DEFAULTGW=fd12:3456:789a:1::fffe MTU=1450 ONBOOT=yes TYPE=Ethernet USERCTL=no

Expected result

The configuration written should differentiate between dhcp6-stateful and dhcp6-stateless. For dhcp6-stateless "DHCPV6C=yes" should be replaced by IPV6_AUTOCONF=yes as shown in the example below.

Created by cloud-init on instance boot automatically, do not edit.

# BOOTPROTO=none DEFROUTE=yes DEVICE=eth0 IPV6_AUTOCONF=yes HWADDR=fa:16:3e:73:0d:96 IPV6INIT=yes IPV6_DEFAULTGW=fd12:3456:789a:1::fffe MTU=1450 ONBOOT=yes TYPE=Ethernet USERCTL=no

The issue starts is in the following code[1]: if 'dhcp' in network['type']: t = 'dhcp6' if network['type'].startswith('ipv6') else 'dhcp4' subnet.update({ 'type': t, })

This makes the assumption that 'ipv6_dhcpv6-stateless' and 'ipv6_dhcpv6-stateful' can be treated the same.

Then in the code[2] the subnet type is checked and DHCPV6C is always used. if subnet_type == 'dhcp6':

TODO need to set BOOTPROTO to dhcp6 on SUSE

    iface_cfg['IPV6INIT'] = True
    iface_cfg['DHCPV6C'] = True

Grepping the source code it looks like this is only affecting cloudinit/net/sysconfig.py.

[1] https://git.launchpad.net/cloud-init/tree/cloudinit/sources/helpers/openstack.py#n587 [2] https://git.launchpad.net/cloud-init/tree/cloudinit/net/sysconfig.py#n346

ubuntu-server-builder commented 1 year ago

Launchpad user Server Team CI bot(server-team-bot) wrote on 2019-10-16T15:30:31.846161+00:00

This bug is fixed with commit fac98983 to cloud-init on branch master. To view that commit see the following URL: https://git.launchpad.net/cloud-init/commit/?id=fac98983

ubuntu-server-builder commented 1 year ago

Launchpad user Chad Smith(chad.smith) wrote on 2019-12-19T22:59:55.250278+00:00

This bug is believed to be fixed in cloud-init in version 19.2-61. If this is still a problem for you, please make a comment and set the state back to New

Thank you.