Closed ubuntu-server-builder closed 1 year ago
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:12:14.571162+00:00
Tested on ubuntu/zesty branch using net-convert.py. Reproduced on Fedora 26 cloud-init 0.7.9 (a few commits behind without netplan)
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:16:49.218008+00:00
Quick-n-dirty hack to get more complete rendered output:
cloudinit/net/sysconfig.py:
205 @classmethod
206 def _render_iface_shared(cls, iface, iface_cfg):
207 print("XXA:", iface, iface_cfg)
208 for k, v in cls.iface_defaults:
209 iface_cfg[k] = v
210
211 for (old_key, new_key) in [('mac_address', 'HWADDR'), ('mtu', 'MTU')]:
212 old_value = iface.get(old_key)
213 if old_value is not None:
214 iface_cfg[new_key] = old_value
215
216 if 'subnets' in iface:
217 for subnet in iface['subnets']:
218 if 'dns_search' in subnet:
219 search_str = ""
220 for i, k in enumerate(subnet['dns_search']):
221 if i > 3:
222 break
223 if i > 0:
224 search_str = search_str + " "
225 search_str = search_str + k
226 iface_cfg['SEARCH'] = search_str
227
228 if 'dns_nameservers' in subnet:
229 ns_str = ""
230 for i, k in enumerate(subnet['dns_nameservers']):
231 if i == 3:
232 break
233 iface_cfg['DNS'+str(i+1)] = k
234
235 if 'gateway' in subnet:
236 iface_cfg['GATEWAY'] = subnet['gateway']
237
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:22:48.378722+00:00
Ouch python indent screwed up, attaching patch instead
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:23:55.890698+00:00
Render DNS1, DNS2, DNS3, SEARCH, GATEWAY lines in sysconfig.py Launchpad attachments: sysconfig.diff
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:34:54.846393+00:00
Typo: 'SEARCH' key should be replaced by 'DOMAIN'
Launchpad user Joshua Powers(powersj) wrote on 2017-07-24T15:55:18.680937+00:00
hi rc556677, thanks for taking the time to file a bug!
There have been numerous recent commits trying to get sysconfig and routes working:
IPv6 Networking and Gateway fixes (LP: #1694801, #1701097) Other networking fixes (LP: #1695092, #1702513) Numerous CentOS networking commits (LP: #1682014, #1701417, #1686856, #1687725)
Would you be willing to try out one of our nightly builds from a COPR repo to see if this has been fixed?
https://copr.fedorainfracloud.org/coprs/g/cloud-init/cloud-init-dev/
Launchpad user rc556677(rc556677) wrote on 2017-07-25T01:33:10.922898+00:00
hi powers,
On Fedora 26 I tested : cloud-init-0.7.9+225.g85c984c-1.fc26.noarch.rpm TL;DR: GATEWAY is fixed in /network-config v1 and ENI; DNS still not fixed with ENI->sysconfig
Results: network-config v1->sysconfig - GATEWAY is now rendered correctly from 'gateway' key directly under a 'subnets' entry; I do not have to nest it under a 'routes'
ENI->sysconfig - GATEWAY is now rendered correctly from 'gateway' under 'network-interfaces' in /meta-data
ENI->sysconfig - /etc/resolv.conf is still not rendered correctly because the dns attr in network-state is empty. The conversion from ENI to network_config does not create any 'type': 'nameserver' entries. _ifaces_to_net_config_data() is not creating a 'type': 'nameserver' entry when it sees 'dns'; instead it creates useless 'dns_nameservers' and 'dns_search' entries under subnets and nobody subsequently consumes these keys.
Launchpad user rc556677(rc556677) wrote on 2017-07-25T01:57:51.517332+00:00
Correction: 'nobody in sysconfig.py', I see that 'dns_nameservers' / 'dns_search' keys in subnets are used by netplan.py.
Launchpad user rc556677(rc556677) wrote on 2017-07-25T02:02:27.371457+00:00
Oh I see: sysconfig.py needs to do the same thing as netplan.py
sysconfig.py is missing this logic:
if 'dns_nameservers' in subnet:
nameservers += _listify(subnet.get('dns_nameservers', []))
if 'dns_search' in subnet:
searchdomains += _listify(subnet.get('dns_search', []))
etc etc
Launchpad user Scott Moser(smoser) wrote on 2017-07-27T13:11:57.923707+00:00
Hi, I think there is enough information to work on here. You did a good job filing the bug, thank you.
I'm curious though, what platform you're running on that is passing ENI format. Is it openstack?
Basically, where did you come to this bug? cloud-init reading ENI and rendering sysconfig is kind of a legacy mode that i'm only aware happens in older versions of openstack (without network_data.json).
thanks.
Launchpad user rc556677(rc556677) wrote on 2017-07-28T01:35:34.837879+00:00
smoser, :-) we were spinning up atomic hosts (CentOS and Fedora) under oVirt with the NoCloud datasources created by scripts. It generated /meta-data+ENI as the lowest-common denominator. To our surprise none of the Fedora 25/26 instances came up correctly :-(.
Launchpad user Scott Moser(smoser) wrote on 2017-11-16T15:56:36.268445+00:00
@rc556677,
OK. that makes sense. I understand the least common denominator approach. Hopefully it wont be too long until you can pass either network config (v1 or v2) everywhere.
For older OSes, we do have daily builds that you update images with. fedora/redhat: https://copr.fedorainfracloud.org/coprs/g/cloud-init/cloud-init/ ubuntu: https://code.launchpad.net/~cloud-init-dev/+archive/ubuntu/daily
I understand daily isn't exactly wonderful either. thanks again for the good bug report.
Launchpad user Scott Moser(smoser) wrote on 2017-12-14T21:22:22.865437+00:00
This bug is believed to be fixed in cloud-init in 17.1. If this is still a problem for you, please make a comment and set the state back to New
Thank you.
This bug was originally filed in Launchpad as LP: #1705804
Launchpad details
Launchpad user rc556677(rc556677) wrote on 2017-07-22T05:10:52.799545+00:00
cloud-init 0.7.9 on CentOS and Fedora are semi-broken because the sysconfig renderer does not render DNS1=... GATEWAY=...
into /etc/sysconfig/network-scripts/ifcfg-eth0. The VM has no default gateway or nameservers.
This is using NoCloud ENI source -> network_config -> network_state -> sysconfig renderer
From this ENI source: auto eth0 iface eth0 inet static address 192.168.125.154 netmask 255.255.255.0 gateway 192.168.125.1 dns-nameservers 192.168.125.1 8.8.8.8 8.8.4.4 1.2.3.4 dns-search example.com foo.biz bar.info foobar.toomany
Actual result:
Created by cloud-init on instance boot automatically, do not edit.
# BOOTPROTO=static DEVICE=eth0 IPADDR=192.168.125.154 NETMASK=255.255.255.0 ONBOOT=yes TYPE=Ethernet USERCTL=no
Expected result:
Created by cloud-init on instance boot automatically, do not edit.
# BOOTPROTO=static DEVICE=eth0 DNS1=192.168.125.1 DNS2=8.8.8.8 DNS3=8.8.4.4 GATEWAY=192.168.125.1 HELLO=world IPADDR=192.168.125.154 NETMASK=255.255.255.0 ONBOOT=yes SEARCH="example.com foo.biz info.bar" TYPE=Ethernet USERCTL=no
The network_config object: {'version': 1, 'config': [{'type': 'physical', 'name': 'eth0', 'subnets': [{'_orig_eni_name': 'eth0', 'type': 'static', 'control': 'auto', 'address': '192.168.125.154', 'netmask': '255.255.255.0', 'gateway': '192.168.125.1', 'dns_nameservers': ['192.168.125.1', '8.8.8.8', '8.8.4.4', '1.2.3.4'], 'dns_search': ['example.com', 'foo.biz', 'bar.info', 'foobar.toomany']}]}]}
The network_state object:
!!python/object:cloudinit.net.network_state.NetworkState _network_state: dns: nameservers: [] search: [] interfaces: eth0: address: null gateway: null inet: inet mac_address: null mode: manual mtu: null name: eth0 subnets: