Comment 13 for bug 1843634

Revision history for this message
Robert Schweikert (rjschwei) wrote :

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.