← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~rjschwei/cloud-init:breakLink into cloud-init:master


Robert Schweikert has proposed merging ~rjschwei/cloud-init:breakLink into cloud-init:master.

Requested reviews:
  cloud-init Commiters (cloud-init-dev)

For more details, see:

If /etc/resolv.conf is a symlink break the link to avoid having our changes clobbered by netconfig
  + netconfig maintains a symlink of /etc/resolv.conf and will write the
    traget of this symlink unconditionally. If the symlink persists when
    cloud-init writes the dns information the cloud-init written user
    configuration gets lost

Your team cloud-init Commiters is requested to review the proposed merge of ~rjschwei/cloud-init:breakLink into cloud-init:master.
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index e381596..44a2f11 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -708,6 +708,12 @@ class Renderer(renderer.Renderer):
             resolv_content = self._render_dns(network_state,
             if resolv_content:
+                # netconfig checks if the resolv file is a link and if that
+                # is true it assumes it is in controil of the file and
+                # will clobber our changes, break the link to ensure the user
+                # configuration sticks
+                if os.path.islink(dns_path):
+                    os.unlink(dns_path)
                 util.write_file(dns_path, resolv_content, file_mode)
         if self.networkmanager_conf_path:
             nm_conf_path = util.target_path(target,

Follow ups