SHA256
1
0
forked from pool/cloud-init

Accepting request 734782 from Cloud:Tools

Automatic submission by obs-autosubmit

OBS-URL: https://build.opensuse.org/request/show/734782
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/cloud-init?expand=0&rev=61
This commit is contained in:
Dominique Leuenberger 2019-10-05 14:16:17 +00:00 committed by Git OBS Bridge
commit 0764e8e2b0
5 changed files with 110 additions and 2 deletions

View File

@ -0,0 +1,13 @@
Index: cloud-init-19.1/systemd/cloud-init.service.tmpl
===================================================================
--- cloud-init-19.1.orig/systemd/cloud-init.service.tmpl
+++ cloud-init-19.1/systemd/cloud-init.service.tmpl
@@ -14,7 +14,7 @@ After=networking.service
After=network.service
{% endif %}
{% if variant in ["suse"] %}
-Before=wicked.service
+After=wicked.service
# setting hostname via hostnamectl depends on dbus, which otherwise
# would not be guaranteed at this point.
After=dbus.service

View File

@ -0,0 +1,68 @@
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index be5dede..1708990 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -578,6 +578,10 @@ class Renderer(renderer.Renderer):
@staticmethod
def _render_dns(network_state, existing_dns_path=None):
+ # skip writing resolv.conf if network_state doesn't include any input.
+ if not any([len(network_state.dns_nameservers),
+ len(network_state.dns_searchdomains)]):
+ return None
content = resolv_conf.ResolvConf("")
if existing_dns_path and os.path.isfile(existing_dns_path):
content = resolv_conf.ResolvConf(util.load_file(existing_dns_path))
@@ -585,8 +589,6 @@ class Renderer(renderer.Renderer):
content.add_nameserver(nameserver)
for searchdomain in network_state.dns_searchdomains:
content.add_search_domain(searchdomain)
- if not str(content):
- return None
header = _make_header(';')
content_str = str(content)
if not content_str.startswith(header):
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index e578992..82eb18f 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -2701,6 +2701,10 @@ USERCTL=no
ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
render_dir = self.tmp_path("render")
os.makedirs(render_dir)
+ # write an etc/resolv.conf and expect it to not be modified
+ resolvconf = os.path.join(render_dir, 'etc/resolv.conf')
+ content = "# Original Content"
+ util.write_file(resolvconf, content)
renderer = self._get_renderer()
renderer.render_network_state(ns, target=render_dir)
found = dir2dict(render_dir)
@@ -2718,6 +2722,8 @@ TYPE=Ethernet
USERCTL=no
"""
self.assertEqual(expected, found[nspath + 'ifcfg-eth0'])
+ # a dhcp only config should not modify resolv.conf
+ self.assertEqual(content, found['/etc/resolv.conf'])
def test_bond_config(self):
expected_name = 'expected_sysconfig_rhel'
@@ -3202,6 +3208,10 @@ USERCTL=no
ns = network_state.parse_net_config_data(CONFIG_V1_EXPLICIT_LOOPBACK)
render_dir = self.tmp_path("render")
os.makedirs(render_dir)
+ # write an etc/resolv.conf and expect it to not be modified
+ resolvconf = os.path.join(render_dir, 'etc/resolv.conf')
+ content = "# Original Content"
+ util.write_file(resolvconf, content)
renderer = self._get_renderer()
renderer.render_network_state(ns, target=render_dir)
found = dir2dict(render_dir)
@@ -3219,6 +3229,8 @@ TYPE=Ethernet
USERCTL=no
"""
self.assertEqual(expected, found[nspath + 'ifcfg-eth0'])
+ # a dhcp only config should not modify resolv.conf
+ self.assertEqual(content, found['/etc/resolv.conf'])
def test_bond_config(self):
expected_name = 'expected_sysconfig_opensuse'

View File

@ -27,7 +27,7 @@
+ # before they are all setup. Settle if that is the case.
+ for iface in network_state.iter_interfaces(
+ renderer.filter_by_physical):
+ path = net.sys_dev_path(iface.name)
+ path = net.sys_dev_path(iface.get('name'))
+ if not os.path.exists(path):
+ util.udevadm_settle(path, 5)
+ break

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Tue Sep 24 19:50:33 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Add cloud-init-after-wicked.patch
- Change the service order, the cloud-init service wants to run after
networking is started
-------------------------------------------------------------------
Tue Sep 24 18:46:00 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Add cloud-init-noresolv-merge-no-dns-data.diff
- Avoid writing resolv.conf if the network configuration contains no
dns entries.
-------------------------------------------------------------------
Mon Sep 23 13:05:03 UTC 2019 - Robert Schweikert <rjschwei@suse.com>
- Follow up to update cloud-init-trigger-udev.patch (bsc#1144363)
- In this implementation the "name" is not yet an attribute, use
get() to obtain the value from a dict. Source code version confusion.
-------------------------------------------------------------------
Mon Aug 19 16:46:35 UTC 2019 - Robert Schweikert <rjschwei@suse.com>

View File

@ -46,8 +46,12 @@ Patch43: cloud-init-write-routes.patch
Patch47: cloud-init-trigger-udev.patch
# FIXME (lp#1669875) patch by mvoelker@launchpad
Patch48: cloud-init-detect-nova.diff
# FIXME (lp##1821102)
# FIXME (lp#1821102)
Patch49: cloud-init-add-static-routes.diff
# FIXME (lp#1843634)
Patch50: cloud-init-noresolv-merge-no-dns-data.diff
# FIXME
Patch51: cloud-init-after-wicked.patch
BuildRequires: fdupes
BuildRequires: filesystem
@ -193,6 +197,8 @@ Documentation and examples for cloud-init tools
%patch47
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%build
%if 0%{?suse_version} && 0%{?suse_version} <= 1315