SHA256
1
0
forked from pool/cloud-init
cloud-init/cloud-init-no-empty-resolv.patch

22 lines
1.0 KiB
Diff

--- 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)