The patch that is in the 19.1 package that is currently distributed in openSUSE and SLE to avoid writing an "empty" config file is as follows:
--- cloudinit/net/sysconfig.py.orig
+++ cloudinit/net/sysconfig.py
@@ -545,6 +545,8 @@ 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 str(content)
header = _make_header(';') content_str = str(content)
if not content_str.startswith(header):
@@ -658,7 +660,8 @@ class Renderer(renderer.Renderer): dns_path = util.target_path(target, self.dns_path) resolv_content = self._render_dns(network_state, existing_dns_path=dns_path)
- util.write_file(dns_path, resolv_content, file_mode)
+ if resolv_content:
+ util.write_file(dns_path, resolv_content, file_mode)
if self.networkmanager_conf_path: nm_conf_path = util.target_path(target, self.networkmanager_conf_path)
This is basically the same as in in "master". In "master" instead of returning an empty string, content is initialized to resolv_conf.ResolvConf(""), None is returned. This means in master "_render_dns()" has different return types, which is a style choice and that's a different discussion.
From a code perspective the package delivers the equivalent to what is in master. Next step for me is to do some testing in Azure.
The patch that is in the 19.1 package that is currently distributed in openSUSE and SLE to avoid writing an "empty" config file is as follows:
--- cloudinit/ net/sysconfig. py.orig 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)
+++ cloudinit/
@@ -545,6 +545,8 @@ class Renderer(
for searchdomain in network_
+ if not str(content):
+ return str(content)
header = _make_header(';')
if not content_
@@ -658,7 +660,8 @@ class Renderer(
- util.write_
+ if resolv_content:
+ util.write_
if self.networkman
This is basically the same as in in "master". In "master" instead of returning an empty string, content is initialized to resolv_ conf.ResolvConf (""), None is returned. This means in master "_render_dns()" has different return types, which is a style choice and that's a different discussion.
From a code perspective the package delivers the equivalent to what is in master. Next step for me is to do some testing in Azure.