Re: [Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
Review: Approve continuous-integration PASSED: Continuous integration, rev:ac38c650c1b6cb9df4021786d772450470f17aff https://jenkins.ubuntu.com/server/job/cloud-init-ci/1176/ Executed test runs: SUCCESS: Checkout SUCCESS: Unit & Style Tests SUCCESS: Ubuntu LTS: Build SUCCESS: Ubuntu LTS: Integration IN_PROGRESS: Declarative: Post Actions Click here to trigger a rebuild: https://jenkins.ubuntu.com/server/job/cloud-init-ci/1176//rebuild -- https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
Review: Approve continuous-integration PASSED: Continuous integration, rev:485384fe14caf0a3da01dfd7d5c79027e2c00161 https://jenkins.ubuntu.com/server/job/cloud-init-ci/1141/ Executed test runs: SUCCESS: Checkout SUCCESS: Unit & Style Tests SUCCESS: Ubuntu LTS: Build SUCCESS: Ubuntu LTS: Integration IN_PROGRESS: Declarative: Post Actions Click here to trigger a rebuild: https://jenkins.ubuntu.com/server/job/cloud-init-ci/1141//rebuild -- https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
Maybe, but I don't think we really wanted to always append a header to the file, and we certainly wanted to avoid writing the file if we didn't have a config. Lastly the side-effect of modifying resolvconf without dns settings disabled system auto-generation. We do need to be careful w.r.t detecting whether netconfig is present or not. I think that we could replace updating resolvconf directly if netconfig is present. This renderer is shared by a range of SuSE and RHEL releases which may or maynot have netconfig (or something equivalent). I'd like Robert to comment on whether we want to move to netconfig or not. That can be done incrementally (land this fix of not touching resolv.conf at all if we don't have settings) and then separately replacing writing resolv.conf directly with using netconfig if present. -- https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
It can be argued that cloud-init *was* doing the right thing. It was told that there were no dns servers and no dns 'search' (by lack of that in network config). dhcp muddies that argument for sure. That said, based on the content in the description of the bug (the previously-existing /etc/resolv.conf), cloud-init should *never* be writing that file when 'netconfig' is involved. It seems rather that resolv.conf is generated based on contents of /etc/sysconfig/network/config . Would writing /etc/sysconfig/network/config with valid content for NETCONFIG_DNS_STATIC_SEARCHLIST and friends fix this? -- https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
Review: Approve continuous-integration PASSED: Continuous integration, rev:cc70b43e9becd6a469ed17430c5907b85b5f2b2d https://jenkins.ubuntu.com/server/job/cloud-init-ci/1139/ Executed test runs: SUCCESS: Checkout SUCCESS: Unit & Style Tests SUCCESS: Ubuntu LTS: Build SUCCESS: Ubuntu LTS: Integration IN_PROGRESS: Declarative: Post Actions Click here to trigger a rebuild: https://jenkins.ubuntu.com/server/job/cloud-init-ci/1139//rebuild -- https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
[Cloud-init-dev] [Merge] ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master
Ryan Harper has proposed merging ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. Commit message: sysconfig: only write resolv.conf if network_state has DNS values If an OS image provided an /etc/resolv.conf file that was not empty cloud-init would read and re-write it with a cloud-init header even if no DNS network configuration was provided (e.g. DHCP only). This can cause problems for some network services which don't ignore cloud-init's header. LP: #1843634 Requested reviews: cloud-init Commiters (cloud-init-dev) Related bugs: Bug #1843634 in cloud-init: "cloud-init misconfigure the network on SLES" https://bugs.launchpad.net/cloud-init/+bug/1843634 For more details, see: https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/372727 -- Your team cloud-init Commiters is requested to review the proposed merge of ~raharper/cloud-init:fix/sysconfig-skip-resolvconf-no-dns-config into cloud-init:master. diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index be5dede..ccc7b85 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -585,7 +585,10 @@ class Renderer(renderer.Renderer): content.add_nameserver(nameserver) for searchdomain in network_state.dns_searchdomains: content.add_search_domain(searchdomain) -if not str(content): +# content may included existing values, 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 header = _make_header(';') content_str = str(content) 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' ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp