canonical / cloud-init

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

cloud-init mishandles dhcp6 subnets in network_data.json #3066

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

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

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2017-11-28T14:20:56.503205+00:00
date_created = 2017-11-27T18:16:52.960486+00:00
date_fix_committed = None
date_fix_released = None
id = 1734739
importance = undecided
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1734739
milestone = None
owner = rmccabe
owner_name = Ryan McCabe
private = False
status = invalid
submitter = rmccabe
submitter_name = Ryan McCabe
tags = []
duplicates = []

Launchpad user Ryan McCabe(rmccabe) wrote on 2017-11-27T18:16:52.960486+00:00

It looks like there's a typo in the helpers/openstack.py network_data.json parser.

With a config like:

{ "links" : [ { "name" : "test", "id" : "test", "type" : "vif" } ], "networks" : [ { "netmask" : "255.255.255.0", "link" : "test", "id" : "test", "ip_address" : "192.168.122.201", "type" : "ipv4", "gateway" : "192.168.122.1" }, { "link" : "test", "id" : "test", "type" : "dhcp6" } ] }

the resulting network state object is

Internal State !!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: !!python/unicode 'test': address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: !!python/unicode 'test' subnets:

When it should be

Internal State !!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: !!python/unicode 'test': address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: !!python/unicode 'test' subnets:

It looks like this is caused by an error on line 570 of helpers/openstack.py where the test used is:

t = 'dhcp6' if network['type'].startswith('ipv6') else 'dhcp4'

which will always result in 'dhcp4' since the network type is 'dhcp6'

it looks like changing the test to

t = 'dhcp6' if network['type'].endswith('6') else 'dhcp4'

fixes things.

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan McCabe(rmccabe) wrote on 2017-11-28T14:20:35.857245+00:00

ovirt will change to match openstack, so that no changes are needed.

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2017-11-28T14:52:43.150796+00:00

Just for historic purposes, Ryan's response here was due to my comment on his merge proposal that sayd:

I'm somewhat disappointed that this passed unit tests.

There are real-ish world examples at bug 1514082 of things like: { "id": "network0", "link": "tap54d10236-5d", "network_id": "a5d1181f-bedd-40a5-8b4a-5574b74dba61", "type": "ipv4_dhcp" },

Did openstack change the 'type' value for dhcp from ipv4_dhcp or ipv6_dhcp to dhcp4 or dhcp6 ?

like you show in your bug?