canonical / cloud-init

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

`cloud-init devel net-convert' broken on SLES, no route is written, missing ifroute-X file #5635

Open jirib opened 3 months ago

jirib commented 3 months ago

Bug report

cloud-init devel net-convert is broken on SLES, no route is written, missing ifroute-X file

Steps to reproduce the problem

Have metadata file and try to convert it to SLES sysconfig, see below.

Environment details

details

$ cat ~/metadata.yaml 
instance-id: cloud-vm
local-hostname: cloud-vm
network:
  version: 2
  ethernets:
    eth0:
      match:
        macaddress: '00:0c:29:21:f1:61'
      dhcp4: false
      addresses:
        - 172.16.171.139/24
      nameservers:
        addresses: [172.16.171.254]
      routes:
        - to: 0.0.0.0/0
          via: 172.16.171.254

$ cloud-init devel net-convert \
    -m eth0,00:0c:29:21:f1:61 \
    --network-data ~/metadata.yaml \
    --kind yaml \
    --output-kind sysconfig \
    -D sles -d ./
Read input format 'yaml' from '/root/metadata.yaml'.
Wrote output format 'sysconfig' to './'

$ find ./etc/
./etc/
./etc/resolv.conf
./etc/NetworkManager
./etc/NetworkManager/conf.d
./etc/NetworkManager/conf.d/99-cloud-init.conf
./etc/udev
./etc/udev/rules.d
./etc/udev/rules.d/85-persistent-net-cloud-init.rules
./etc/sysconfig
./etc/sysconfig/network
./etc/sysconfig/network/ifcfg-eth0

$ cat ./etc/sysconfig/network/ifcfg-eth0 
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=static
IPADDR=172.16.171.139
LLADDR=00:0c:29:21:f1:61
NETMASK=255.255.255.0
STARTMODE=auto

However, cloud-init itself seems to work fine:

$ grep -H '' /etc/sysconfig/network/*eth0*
/etc/sysconfig/network/ifcfg-eth0:# Created by cloud-init on instance boot automatically, do not edit.
/etc/sysconfig/network/ifcfg-eth0:#
/etc/sysconfig/network/ifcfg-eth0:BOOTPROTO=static
/etc/sysconfig/network/ifcfg-eth0:IPADDR=172.16.171.139
/etc/sysconfig/network/ifcfg-eth0:LLADDR=00:0c:29:21:f1:61
/etc/sysconfig/network/ifcfg-eth0:NETMASK=255.255.255.0
/etc/sysconfig/network/ifcfg-eth0:STARTMODE=auto
/etc/sysconfig/network/ifroute-eth0:0.0.0.0/0 172.16.171.254 - -

$  ip r s
default via 172.16.171.254 dev eth0 
172.16.171.0/24 dev eth0 proto kernel scope link src 172.16.171.139 

$ cat /etc/resolv.conf 
; Created by cloud-init on instance boot automatically, do not edit.
;
nameserver 172.16.171.254
TheRealFalcon commented 2 months ago

@jirib , thanks for filing the issue.

This looks like a place where upstream and downstream have diverged somewhat. Patches have been added downstream so that routes get rendered properly on SUSE. Since this code lives downstream, there's not really anything we can do upstream to render the route files. The code either needs to gets added upstream or the feature request should be made to the distribution carrying the patch.

@rjschwei , do you happen to know why this patch is still being carried downstream? Is there any reason we can't upstream it?

rjschwei commented 2 months ago

Currently we still have a big patch [1] for routing setup because I have never had the time to push an upstream implementation that used the newer config format.

This is a matter of available time on my part, or someone else's time and interest.

[1] https://build.opensuse.org/projects/Cloud:Tools/packages/cloud-init/files/cloud-init-write-routes.patch?expand=1