Bug 1489415 - cloud-init fails to set static ip settings
Summary: cloud-init fails to set static ip settings
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.4
Hardware: x86_64
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Ryan McCabe
QA Contact: Vladimir
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-07 12:13 UTC by Ilkka Tengvall
Modified: 2018-04-10 14:05 UTC (History)
14 users (show)

Fixed In Version: cloud-init-0.7.9-17.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 14:05:07 UTC
Target Upstream Version:


Attachments (Terms of Use)
network-config used to reproduce this and the error log (2.93 KB, text/plain)
2017-09-07 12:13 UTC, Ilkka Tengvall
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0806 0 normal SHIPPED_LIVE cloud-init bug fix and enhancement update 2018-04-10 12:40:54 UTC

Description Ilkka Tengvall 2017-09-07 12:13:08 UTC
Created attachment 1323079 [details]
network-config used to reproduce this and the error log

Description of problem:

I try to run virtual RHEL instances on KVM, and feed static network settings via cloud-init CD. Cloud init fails to set the network settings, so the guest VM starts unavailable to connect to. I expect the machine to boot up with IP address where I can ssh into, and connect to network from VM.


Version-Release number of selected component (if applicable):

cloud-init-0.7.9-9.el7.x86_64

How reproducible:

every time

Steps to Reproduce:
1. create cloud-init CD with network-config file
1. create vm with libvirt
2. login to VM via console, as network won't be in given IP
3.

Actual results:

Mahcine does not respond from given IP.


Expected results:

I could login via ssh into the machine.

Additional info:

Here's the network-config: https://github.com/ikke-t/ocp-libvirt-infra-ansibles/blob/network-config/playbooks/roles/virtuals/templates/network-config.j2

Here is a reproducal ansible to run on given RHEL which sets up a machine using cloud-init: https://github.com/ikke-t/ocp-libvirt-infra-ansibles/tree/network-config

Cloud-init network-config instructions: http://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html#network-config-v2


Attached the network-config file and the error log.

Comment 2 Ilkka Tengvall 2017-09-07 12:45:49 UTC
Before someone tells to use the RH guided way I can tell it's broken too:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_atomic_host/7/html/installation_and_configuration_guide/setting_up_cloud_init

It does not set up gateway nor DNS server, so the machine is without the network that way too.

Comment 3 Ryan McCabe 2017-09-07 13:51:18 UTC
Is this a regression from older versions for you, or are you trying now for the first time?

Comment 4 Ryan McCabe 2017-09-07 16:34:57 UTC
Looking more closely at your config, could you try removing the first line ("network:") and see if that solves the issue?

Comment 5 Ilkka Tengvall 2017-09-08 12:15:59 UTC
I did do that, and it still fails. It still creates the DHCP config for eth0. This is the error in the logs now:

2017-09-08 03:13:14,313 - util.py[DEBUG]: Attempting to load yaml from string of length 1821 with allowed root types (<type 'dict'>,)
2017-09-08 03:13:14,317 - util.py[DEBUG]: Attempting to load yaml from string of length 0 with allowed root types (<type 'dict'>,)
2017-09-08 03:13:14,317 - util.py[DEBUG]: load_yaml given empty string, returning default
2017-09-08 03:13:14,317 - stages.py[DEBUG]: applying net config names for {'ethernets': {'eth0': {'nameservers': {'addresses': ['8.8.8.8']}, 'gateway4': '192.1
68.122.1', 'addresses': ['192.168.122.2/24'], 'dhcp4': False}}, 'version': 2}
2017-09-08 03:13:14,318 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.rhel.Distro'>
2017-09-08 03:13:14,318 - __init__.py[DEBUG]: no interfaces to rename
2017-09-08 03:13:14,318 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'ethernets': {'eth0': {'nameservers': {'addresses': ['8.8.8.8
']}, 'gateway4': '192.168.122.1', 'addresses': ['192.168.122.2/24'], 'dhcp4': False}}, 'version': 2}
2017-09-08 03:13:14,318 - util.py[WARNING]: failed stage init-local
2017-09-08 03:13:14,319 - util.py[DEBUG]: failed stage init-local
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 513, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 269, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 642, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/__init__.py", line 150, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 60, in _write_network_config
    self._net_renderer.render_network_state("/", ns)
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 509, in render_network_state
    network_state).items():
  File "/usr/lib/python2.7/site-packages/cloudinit/net/sysconfig.py", line 483, in _render_sysconfig
    for iface in network_state.iter_interfaces():
AttributeError: 'NoneType' object has no attribute 'iter_interfaces'
2017-09-08 03:13:14,351 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2017-09-08 03:13:14,351 - util.py[DEBUG]: Read 10 bytes from /proc/uptime
2017-09-08 03:13:14,351 - util.py[DEBUG]: cloud-init mode 'init' took 0.538 seconds (0.54)
2017-09-08 03:13:14,352 - handlers.py[DEBUG]: finish: init-local: SUCCESS: searching for local datasources

Comment 6 Ilkka Tengvall 2017-09-08 12:19:25 UTC
btw, this was the content of network-config file, it get's parsed ok it seems:

# cat /tmp/bastion/network-config 
version: 2
ethernets:
  eth0:
    dhcp4: false
    addresses:
      - 192.168.122.2/24
    gateway4: 192.168.122.1
    nameservers:
      addresses: [8.8.8.8]

Comment 7 Ilkka Tengvall 2017-09-08 12:20:57 UTC
(In reply to Ryan McCabe from comment #3)
> Is this a regression from older versions for you, or are you trying now for
> the first time?

I'm trying it for the first time, no regression that I could point out.

Comment 8 Ryan McCabe 2017-11-06 03:20:35 UTC
Could you try using the network_data.json format to pass in network settings. We don't have netplan (v2) support on rhel (or fedora).

Comment 9 Ilkka Tengvall 2017-11-07 05:53:51 UTC
what exactly to do here? I tried converting the network-data into json, and pasting it into file network_data.json and regenerated the config CD. Content of the file was now:

{
  "network": {
    "version": 2,
    "ethernets": {
      "eth0": {
        "dhcp4": false,
        "addresses": [
          "192.168.122.5/24"
        ],
        "gateway4": "192.168.122.1",
        "nameservers": {
          "addresses": [
            "8.8.8.8"
          ]
        }
      }
    }
  }
}


No network config got applied. I also tried renaming the file back to network-config within the CD, doesn't work either. Do you have any link to instructions on how to do that?

How should the network config be put into CD? What filename and which is the correct json format within the file?

Comment 13 Vladimir 2017-12-28 15:59:43 UTC
Verified using cloud-init version 0.7.9.20
Using metadata format as per https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_atomic_host/7/html/installation_and_configuration_guide/setting_up_cloud_init

Comment 14 Vladimir 2018-01-16 12:58:10 UTC
Addition to the comment above:
RHEL version: 7.4
RHEVM version: 4.2.0.2-0.1.el7

Comment 15 Ilkka Tengvall 2018-01-22 10:43:29 UTC
When will this be included into qcow image for KVM on the download page? That image is broken until it's included, currently it has this version according to details page: cloud-init-0.7.9-9.el7_4.1.x86_64.rpm 

https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.4/x86_64/product-software

Comment 16 meital avital 2018-01-30 09:44:35 UTC
According to comment #14 moving to verified

Comment 19 errata-xmlrpc 2018-04-10 14:05:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:0806


Note You need to log in before you can comment on or make changes to this bug.