cloud-init misconfigure the network on SLES
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
High
|
Robert Schweikert | ||
cloud-init (Suse) |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
cloud-init's sysconfig renderer injects the cloud-init header even
if no DNS configuration is provided in network-config.
cloud-init.service may need to update service file with additional
wicked service names to ensure that networking is up before starting.
[Original Description]
I reproduced the issue on an Azure VM with SLES12 SP4 and cloud-init 19.1.
The DNS is unreachable when cloud-init takes the responsibility of configuring the network. No nameservers or search domains are added to the /etc/resolv.conf as following:
; Created by cloud-init on instance boot automatically, do not edit.
;
### /etc/resolv.conf file autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/
# NETCONFIG_
# NETCONFIG_
# NETCONFIG_
# or disable DNS configuration updates via netconfig by setting:
# NETCONFIG_
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
I also attached the "/etc/sysconfig
When I disable the network configuration in cloud-init and leave it for netconfig, the /etc/resolv.conf is correctly populated with the search domain and the nameserver and the DNS is reachable. Here's the contents of the /etc/resolv.conf:
### /etc/resolv.conf file autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/
# NETCONFIG_
# NETCONFIG_
# NETCONFIG_
# or disable DNS configuration updates via netconfig by setting:
# NETCONFIG_
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
search xkf00b0rtzgejku
nameserver 168.63.129.16
When I tried to populate the network config dictionary that's built by DataSourceAzure with a default nameserver "168.63.129.16" and search domain "xkf00b0rtzgejk
Another issue is the eth0 interface is not brought up automatically even though the contents of the file "/etc/sysconfig
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
HWADDR=
NM_CONTROLLED=no
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
I had to bring it up by executing "ifup eth0" from Azure.py code after the network config is applied. This way I was able to ssh into the VM.
Here's also the contents of "etc/udev/
Related branches
- Server Team CI bot: Approve (continuous-integration)
- Dan Watkins: Approve
-
Diff: 68 lines (+16/-2)2 files modifiedcloudinit/net/sysconfig.py (+4/-2)
tests/unittests/test_net.py (+12/-0)
Changed in cloud-init (Suse): | |
status: | New → Incomplete |
description: | updated |
Changed in cloud-init: | |
status: | Triaged → In Progress |
Changed in cloud-init: | |
assignee: | nobody → Robert Schweikert (rjschwei) |
OK, thanks for the logs. Could you re-attach those running via sudo (or as root)? The default user on SLES does not have permissions to read the journal.
What I see so far looks like networking did not come up after cloud-init- local.service completes and writes out a network config.
2019-09-11 18:00:15,242 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'ethernets': {'eth0': {'set-name': 'eth0', 'match': {'macaddress': u'00:0d: 3a:6e:6f: 8f'}, 'dhcp4': True}}, 'version': 2}
This results in the following files being written:
% cat test_azure_ sles/etc/ sysconfig/ network/ ifcfg-eth0 00:0d:3a: 6e:6f:8f
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
HWADDR=
NM_CONTROLLED=no
ONBOOT=yes
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
Upstream cloud-init on SLES does not generate/update /etc/resolv.conf but in the logs the cloud-init in does:
2019-09-11 18:00:15,246 - util.py[DEBUG]: Writing to /etc/sysconfig/ network/ ifcfg-eth0 - wb: [644] 191 bytes
2019-09-11 18:00:15,247 - util.py[DEBUG]: Reading from /etc/resolv.conf (quiet=False)
2019-09-11 18:00:15,247 - util.py[DEBUG]: Read 795 bytes from /etc/resolv.conf
2019-09-11 18:00:15,247 - util.py[DEBUG]: Writing to /etc/resolv.conf - wb: [644] 866 bytes
At first, I thought maybe it was missing this commit:
% git show b74ebca563a2133 2b29482c8029e79 08f60225a4 2b29482c8029e79 08f60225a4
commit b74ebca563a2133
Author: Robert Schweikert <email address hidden>
Date: Wed Jan 23 22:35:32 2019 +0000
net/sysconfig: do not write a resolv.conf file with only the header.
Writing the file with no dns information may prevent distro tools
from writing a resolv.conf file with dns information obtained from
a dhcp server.
diff --git a/cloudinit/ net/sysconfig. py b/cloudinit/ net/sysconfig. py net/sysconfig. py net/sysconfig. py renderer. Renderer) :
content. add_nameserver( nameserver) state.dns_ searchdomains:
content. add_search_ domain( searchdomain)
content_ str = str(content) str.startswith( header) : renderer. Renderer) :
dns_ path = util.target_ path(target, self.dns_path)
resolv_ content = self._render_ dns(network_ state,
existing_ dns_path= dns_path) file(dns_ path, resolv_content, file_mode) file(dns_ path, resolv_content, file_mode) ager_conf_ path:
nm_ conf_path = util.target_ path(target,
self. networkmanager_ conf_path) unittests/ test_net. py b/tests/ unittests/ test_net. py unittests/ test_net. py unittests/ test_net. py
self. assertEqual( expected, found[nspath + 'ifcf...
index ae41f7b..fd8e501 100644
--- a/cloudinit/
+++ b/cloudinit/
@@ -557,6 +557,8 @@ class Renderer(
for searchdomain in network_
+ if not str(content):
+ return None
header = _make_header(';')
if not content_
@@ -666,7 +668,8 @@ class Renderer(
- util.write_
+ if resolv_content:
+ util.write_
if self.networkman
diff --git a/tests/
index d679e92..5313d2d 100644
--- a/tests/
+++ b/tests/
@@ -2098,6 +2098,10 @@ TYPE=Ethernet
USERCTL=no
"""