sysconfig renderer does not render gateway settings in ifcfg-$iface files

Bug #1686856 reported by Ryan Harper on 2017-04-27
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
cloud-init
Undecided
Unassigned
oVirt
Unknown
High
CentOS
Unknown
Undecided

Bug Description

cloud-init trunk with the following network config:

network:
    version: 1
    config:
        - type: physical
          name: interface0
          mac_address: "52:54:00:12:34:00"
          subnets:
              - type: static
                address: 10.0.2.15
                netmask: 255.255.255.0
                gateway: 10.0.2.2

renders an ifcfg-interface0 file without a GATEWAY=10.0.2.2

% cat /etc/sysconfig/network-scripts/ifcfg-interface0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=static
DEVICE=interface0
HWADDR=52:54:00:12:34:00
IPADDR=10.0.2.15
NETMASK=255.255.255.0
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

Subsequently, route -n shows that a default gateway is not set.

% route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 interface0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 interface0

If you add GATEWAY=10.0.2.2 you see a route like this:

% route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 interface0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 interface0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 interface0

Download full text (7.8 KiB)

Description of problem:
on latest version of cloud-init, it does not apply the default gateway on RHEL 7.4 vm.
Seen using the no-cloud provider with a static networking configuration.

 [root@enginevm ~]# nmcli con show "System eth0" | grep -i GATEWAY
 connection.gateway-ping-timeout: 0
 ipv4.gateway: --
 ipv6.gateway: --
 IP4.GATEWAY: --
 IP6.GATEWAY: fe80::c4ee:3eff:fed5:fad9
 [root@enginevm ~]# nmcli con modify "System eth0" ipv4.gateway
 Error: value for 'ipv4.gateway' is missing.
 [root@enginevm ~]#
 [root@enginevm ~]# nmcli con show "System eth0" | grep -i GATEWAY
 connection.gateway-ping-timeout: 0
 ipv4.gateway: --
 ipv6.gateway: --
 IP4.GATEWAY: --
 IP6.GATEWAY: fe80::c4ee:3eff:fed5:fad9
 [root@enginevm ~]# nmcli con modify "System eth0" ipv4.gateway 192.168.1.1
 [root@enginevm ~]# nmcli con reload "System eth0"
 [root@enginevm ~]# nmcli con up "System eth0"
 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
 [root@enginevm ~]# nmcli con show "System eth0" | grep -i GATEWAY
 connection.gateway-ping-timeout: 0
 ipv4.gateway: 192.168.1.1
 ipv6.gateway: --
 IP4.GATEWAY: 192.168.1.1
 IP6.GATEWAY: fe80::c4ee:3eff:fed5:fad9
 [root@enginevm ~]# mount /dev/sr0 /mnt/
 mount: /dev/sr0 is write-protected, mounting read-only
 [root@enginevm ~]# cat /mnt/meta-data
 instance-id: d8b22f43-1565-44e2-916f-f211c7e07f13
 local-hostname: enginevm.localdomain
 network-interfaces: |
   auto eth0
   iface eth0 inet static
     address 192.168.1.204
     network 192.168.1.0
     netmask 255.255.255.0
     broadcast 192.168.1.255
     gateway 192.168.1.1

under /var/log/messages:
Sep 18 09:47:34 localhost cloud-init: Cloud-init v. 0.7.9 running 'init' at Mon, 18 Sep 2017 09:47:34 +0000. Up 8.48 seconds.
Sep 18 09:47:34 localhost cloud-init: ci-info: +++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++
Sep 18 09:47:34 localhost cloud-init: ci-info: +--------+------+---------------+---------------+-------+-------------------+
Sep 18 09:47:34 localhost cloud-init: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
Sep 18 09:47:34 localhost cloud-init: ci-info: +--------+------+---------------+---------------+-------+-------------------+
Sep 18 09:47:34 localhost cloud-init: ci-info: | lo: | True | 127.0.0.1 | 255.0.0.0 | . | . |
Sep 18 09:47:34 localhost cloud-init: ci-info: | lo: | True | . | . | d | . |
Sep 18 09:47:34 localhost cloud-init: ci-info: | eth0: | True | 192.168.1.204 | 255.255.255.0 | . | 00:16:3e:10:dc:25 |
Sep 18 09:47:34 localhost cloud-init: ci-info: | eth0: | True | . | . | d | 00:16:3e:10:dc:25 |
Sep 18 09:47:34 localhost cloud-init: ci-info: +--------+------+---------------+------...

Read more...

[root@enginevm ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEVICE=eth0
IPADDR=192.168.1.204
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
DNS1=192.168.1.1
DNS2=8.8.8.8
DOMAIN=localdomain

Description of problem:
Due to an upstream cloud-init bug ( https://bugs.launchpad.net/cloud-init/+bug/1686856 ), the default gateway is not configured on the Engine VM if deployed with static IP.

It affects RHEL 7.4 and Centos 7.4 (used as the base of the engine-appliance, not related to host OS).

Version-Release number of selected component (if applicable):
The issue is cloud-init on the engine VM OS: 7.4

How reproducible:
100%

Steps to Reproduce:
1. deploy hosted-engine with static IP for the engine VM
2.
3.

Actual results:
The engine VM has no gateway and so no network connectivity

Expected results:
The default gateway on the engine VM is correctly configured

Additional info:

It affects RHEL 7.4 and Centos 7.4 (used as the base of the engine-appliance, not related to host OS)

This is a regression, should be considered as blocker for next cloud-init release.
Any ETA on fixing this?

tags: added: ovirt

Proposing for backport to 7.4 too

Not depending on bug #1492726 since we can workaround it. Moved bug #1492726 to see also.

*** Bug 1493070 has been marked as a duplicate of this bug. ***

Ryan Harper (raharper) wrote :

This is fixed in trunk @ d1e8eb73aca6a3f5cee415774dcf540e934ec250

This will be included in the next cloud-init release:

https://lists.launchpad.net/cloud-init/msg00100.html

Changed in cloud-init:
status: New → Fix Committed

Thanks!

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.

Changed in cloud-init:
status: Fix Committed → Fix Released

Moving back to assigned. The fix upstream is incomplete. Still waiting for them to pull the complete fixes in. The latest release (17.1) and the master branch are still broken.

Ryan McCabe (rmccabe) wrote :

This still appears to be broken in 17.1 and master:

$ cat yaml.txt
network:
    version: 1
    config:
        - type: physical
          name: interface0
          mac_address: "52:54:00:12:34:00"
          subnets:
              - type: static
                address: 10.0.2.15
                netmask: 255.255.255.0
                gateway: 10.0.2.2

$ ./net-convert.py --network-data yaml.txt -d out/ --kind yaml --output-kind sysconfig

$ find out -type f
out/etc/udev/rules.d/70-persistent-net.rules
out/etc/resolv.conf
out/etc/sysconfig/network-scripts/ifcfg-interface0

$ find out -type f -print0|xargs -0 cat
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:12:34:00", NAME="interface0"
; Created by cloud-init on instance boot automatically, do not edit.
;
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=static
DEVICE=interface0
HWADDR=52:54:00:12:34:00
IPADDR=10.0.2.15
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

Ryan McCabe (rmccabe) wrote :

Ignore the above, please. I had stale bits lying around that were causing it to use old code. It does render the GATEWAY line in sysconfig for me now on master after I've cleaned up.

..and moving back to POST. I had stale bits from 0.7.9 lying around that were being used while I was testing. The upstream fix does seem to resolve GATEWAY not being written out.

Successfully deployed SHE with static IP using cloud-init, over NFS on RHEL7.4 host, using rhvm-appliance-4.1.20170927.0-1.el7.noarch with ovirt-engine-setup-4.1.7.1-0.1.el7.noarch inside and ovirt-hosted-engine-setup-2.1.4-1.el7ev.noarch on host.
Moving to verified.

Changed in ovirt:
importance: Unknown → High
Changed in centos:
importance: Unknown → Undecided
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.