Re: [Cloud-init-dev] [Merge] ~rmccabe/cloud-init:bug1705804-4 into cloud-init:master
Yeah, some combination of misclicks landed this in "needs review" from superseded, and I didn't see a way to put it back to there. -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333844 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-4 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] ~rmccabe/cloud-init:bug1705804-4 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1705804-4 into cloud-init:master. Commit message: sysconfig: Correctly render dns and dns search info. Currently when dns and dns search info is provided, it is not rendered when outputting to sysconfig format. This patch causes the DNS and DOMAIN lines to be written out rendering sysconfig. LP: #1705804 Requested reviews: cloud-init commiters (cloud-init-dev) Server Team CI bot (server-team-bot): continuous-integration Related bugs: Bug #1705804 in cloud-init: "sysconfig renderer should render DNSx= and GATEWAY= lines" https://bugs.launchpad.net/cloud-init/+bug/1705804 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333844 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-4 into cloud-init:master. diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index 0e830ee..0af0f54 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -325,13 +325,24 @@ class NetworkStateInterpreter(object): # convert subnet ipv6 netmask to cidr as needed subnets = _normalize_subnets(command.get('subnets')) +# listify per-subnet dns and # automatically set 'use_ipv6' if any addresses are ipv6 -if not self.use_ipv6: -for subnet in subnets: +for subnet in subnets: +if not self.use_ipv6: if (subnet.get('type').endswith('6') or is_ipv6_addr(subnet.get('address'))): self.use_ipv6 = True break +if 'dns_search' in subnet: +paths = subnet['dns_search'] +if not isinstance(paths, list): +paths = paths.split() +subnet['dns_search'] = paths +if 'dns_nameservers' in subnet: +addrs = subnet['dns_nameservers'] +if not type(addrs) == list: +addrs = addrs.split() +subnet['dns_nameservers'] = addrs iface.update({ 'name': command.get('name'), diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index f572796..6b0b007 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -347,6 +347,13 @@ class Renderer(renderer.Renderer): else: iface_cfg['GATEWAY'] = subnet['gateway'] +if 'dns_search' in subnet: +iface_cfg['DOMAIN'] = ' '.join(subnet['dns_search']) + +if 'dns_nameservers' in subnet: +for i, k in enumerate(subnet['dns_nameservers'][:3], 1): +iface_cfg['DNS' + str(i)] = k + @classmethod def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index bbb63cb..f3fa2a3 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -436,6 +436,9 @@ NETWORK_CONFIGS = { BOOTPROTO=dhcp DEFROUTE=yes DEVICE=eth99 +DNS1=8.8.8.8 +DNS2=8.8.4.4 +DOMAIN="barley.maas sach.maas" GATEWAY=65.61.151.37 HWADDR=c0:d6:9f:2c:e8:80 IPADDR=192.168.21.3 @@ -836,6 +839,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEFROUTE=yes DEVICE=eth0.101 +DNS1=192.168.0.10 +DNS2=10.23.23.134 +DOMAIN="barley.maas sacchromyces.maas brettanomyces.maas" GATEWAY=192.168.0.1 IPADDR=192.168.0.2 IPADDR1=192.168.2.10 ___ 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] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master
The proposal to merge ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master has been updated. Status: Needs review => Superseded For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333759 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
The proposal to merge ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master has been updated. Status: Superseded => Needs review For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
Sorry, what I meant re: "dns-nameservers 69.9.160.191 69.9.191.4 10.0.0.1" is that the first two IPs were pulled from an ethX interface and don't belong there, given the yaml, not that there was a problem with the syntax. ACK, re: Scott's comment I'll resubmit a proposal that does only the listify and cleans up the split -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
Diff comments: > diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py > index f572796..6e11247 100644 > --- a/cloudinit/net/sysconfig.py > +++ b/cloudinit/net/sysconfig.py > @@ -347,6 +347,16 @@ class Renderer(renderer.Renderer): > else: > iface_cfg['GATEWAY'] = subnet['gateway'] > > +if 'dns_search' in subnet: > +if isinstance(subnet['dns_search'], (list, tuple)): Is adding the dns search and nameservers info into the network_state dict the right thing to do here? It looks like dns info from all interfaces, not just subnets of the current one, is being added, and it produces bad output e.g.,: iface lo inet loopback dns-nameservers 69.9.160.191 69.9.191.4 10.0.0.1 dns-search foo.com when it should be iface lo inet loopback dns-nameservers 10.0.0.1 dns-search foo.com Doing only the listify and not adding the info to the network_state dict there seems to do the right thing. > + iface_cfg['DOMAIN'] = ' > '.join(subnet['dns_search'][:3]) > +else: > + iface_cfg['DOMAIN'] = subnet['dns_search'] > + > +if 'dns_nameservers' in subnet: > +for i, k in enumerate(subnet['dns_nameservers'][:3], 1): > +iface_cfg['DNS' + str(i)] = k > + > @classmethod > def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): > for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 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] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master
The unit tests will fail on this one until the patch you suggested is applied, btw, because of the dns search info being passed as a list. -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333758 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 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] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master
Updated per your last comments for merge after your fixes. -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333759 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 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] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master
The proposal to merge ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master has been updated. Status: Needs review => Superseded For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333758 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 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] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) Server Team CI bot (server-team-bot): continuous-integration Related bugs: Bug #1705804 in cloud-init: "sysconfig renderer should render DNSx= and GATEWAY= lines" https://bugs.launchpad.net/cloud-init/+bug/1705804 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333759 Currently when dns and dns search info is provided, it is not rendered when outputting to sysconfig format. This patch causes the DNS and DOMAIN lines to be written out rendering sysconfig. LP: #1705804 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master. diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index f572796..a3f23bd 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -347,6 +347,13 @@ class Renderer(renderer.Renderer): else: iface_cfg['GATEWAY'] = subnet['gateway'] +if 'dns_search' in subnet: +iface_cfg['DOMAIN'] = subnet['dns_search'] + +if 'dns_nameservers' in subnet: +for i, k in enumerate(subnet['dns_nameservers'][:3], 1): +iface_cfg['DNS' + str(i)] = k + @classmethod def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index bbb63cb..f3fa2a3 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -436,6 +436,9 @@ NETWORK_CONFIGS = { BOOTPROTO=dhcp DEFROUTE=yes DEVICE=eth99 +DNS1=8.8.8.8 +DNS2=8.8.4.4 +DOMAIN="barley.maas sach.maas" GATEWAY=65.61.151.37 HWADDR=c0:d6:9f:2c:e8:80 IPADDR=192.168.21.3 @@ -836,6 +839,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEFROUTE=yes DEVICE=eth0.101 +DNS1=192.168.0.10 +DNS2=10.23.23.134 +DOMAIN="barley.maas sacchromyces.maas brettanomyces.maas" GATEWAY=192.168.0.1 IPADDR=192.168.0.2 IPADDR1=192.168.2.10 ___ 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
The proposal to merge ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master has been updated. Status: Needs review => Superseded For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
Updated to handle dns_search when received as either a string or a list Updated per Ryan Harper's other comments on the previous iteration -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 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] ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) Related bugs: Bug #1705804 in cloud-init: "sysconfig renderer should render DNSx= and GATEWAY= lines" https://bugs.launchpad.net/cloud-init/+bug/1705804 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333722 Currently when dns and dns search info is provided, it is not rendered when outputting to sysconfig format. This patch causes the DNS and DOMAIN lines to be written out rendering sysconfig. LP: #1705804 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-2 into cloud-init:master. diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index f572796..6e11247 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -347,6 +347,16 @@ class Renderer(renderer.Renderer): else: iface_cfg['GATEWAY'] = subnet['gateway'] +if 'dns_search' in subnet: +if isinstance(subnet['dns_search'], (list, tuple)): + iface_cfg['DOMAIN'] = ' '.join(subnet['dns_search'][:3]) +else: + iface_cfg['DOMAIN'] = subnet['dns_search'] + +if 'dns_nameservers' in subnet: +for i, k in enumerate(subnet['dns_nameservers'][:3], 1): +iface_cfg['DNS' + str(i)] = k + @classmethod def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index bbb63cb..f3fa2a3 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -436,6 +436,9 @@ NETWORK_CONFIGS = { BOOTPROTO=dhcp DEFROUTE=yes DEVICE=eth99 +DNS1=8.8.8.8 +DNS2=8.8.4.4 +DOMAIN="barley.maas sach.maas" GATEWAY=65.61.151.37 HWADDR=c0:d6:9f:2c:e8:80 IPADDR=192.168.21.3 @@ -836,6 +839,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEFROUTE=yes DEVICE=eth0.101 +DNS1=192.168.0.10 +DNS2=10.23.23.134 +DOMAIN="barley.maas sacchromyces.maas brettanomyces.maas" GATEWAY=192.168.0.1 IPADDR=192.168.0.2 IPADDR1=192.168.2.10 ___ 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] ~rmccabe/cloud-init:bug1705804 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1705804 into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) Related bugs: Bug #1705804 in cloud-init: "sysconfig renderer should render DNSx= and GATEWAY= lines" https://bugs.launchpad.net/cloud-init/+bug/1705804 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333663 Currently when dns and dns search info is provided in ENI format, it is not rendered when outputting to sysconfig format. This patch writes it out when converting ENI -> sysconfig LP: #1705804 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804 into cloud-init:master. diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index f572796..da21af0 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -347,6 +347,16 @@ class Renderer(renderer.Renderer): else: iface_cfg['GATEWAY'] = subnet['gateway'] +if 'dns_search' in subnet: +search_str = ' '.join(subnet['dns_search'][:3]) +iface_cfg['DOMAIN'] = search_str + +if 'dns_nameservers' in subnet: +for i, k in enumerate(subnet['dns_nameservers'], 1): +if i > 3: +break +iface_cfg['DNS' + str(i)] = k + @classmethod def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets): for i, subnet in enumerate(subnets, start=len(iface_cfg.children)): diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index bbb63cb..4dc950f 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -436,6 +436,9 @@ NETWORK_CONFIGS = { BOOTPROTO=dhcp DEFROUTE=yes DEVICE=eth99 +DNS1=8.8.8.8 +DNS2=8.8.4.4 +DOMAIN="b a r" GATEWAY=65.61.151.37 HWADDR=c0:d6:9f:2c:e8:80 IPADDR=192.168.21.3 @@ -836,6 +839,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEFROUTE=yes DEVICE=eth0.101 +DNS1=192.168.0.10 +DNS2=10.23.23.134 +DOMAIN="barley.maas sacchromyces.maas brettanomyces.maas" GATEWAY=192.168.0.1 IPADDR=192.168.0.2 IPADDR1=192.168.2.10 ___ 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] ~rmccabe/cloud-init:dns_redirect_detect into cloud-init:master
Thanks! -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/328877 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:dns_redirect_detect 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] ~rmccabe/cloud-init:dns_redirect_detect into cloud-init:master
There is a Red Hat bugzilla regarding it at https://bugzilla.redhat.com/show_bug.cgi?id=1468192 Should I create one here? -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/328877 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:dns_redirect_detect 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] ~rmccabe/cloud-init:dns_redirect_detect into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:dns_redirect_detect into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/328877 Add an option to disable DNS redirection detection. Add a config option, disable_dns_redirection_detection, that can be used to disable the code that attempts to determine if DNS requests are being redirected. The DNS redirection detection can cause long delays at boot when no DNS servers are available. It also causes issues with some intrusion detection systems. I wasn't sure the best place to stick this new config value. This seemed like the least intrusive way to do it. If there's another way you'd like to see this done, please let me know. -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:dns_redirect_detect into cloud-init:master. diff --git a/cloudinit/stages.py b/cloudinit/stages.py index a1c4a51..67ffeae 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -141,8 +141,14 @@ class Init(object): return len(rm_list) def initialize(self): +self._initialize_global_options() self._initialize_filesystem() +def _initialize_global_options(self): +dns_detect = self.cfg.get('disable_dns_redirection_detection') +if util.translate_bool(dns_detect): +util.disable_dns_redirection_detection() + def _initialize_filesystem(self): util.ensure_dirs(self._initial_subdirs()) log_file = util.get_cfg_option_str(self.cfg, 'def_log_file') diff --git a/cloudinit/util.py b/cloudinit/util.py index ce2c603..de34210 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1119,6 +1119,12 @@ def get_fqdn_from_hosts(hostname, filename="/etc/hosts"): return fqdn +def disable_dns_redirection_detection(): +global _DNS_REDIRECT_IP +_DNS_REDIRECT_IP = set() +LOG.debug("disabled DNS redirection detection") + + def is_resolvable(name): """determine if a url is resolvable, return a boolean This also attempts to be resilent against dns redirection. diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index bd84c64..bc643e3 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -403,6 +403,11 @@ timezone: US/Eastern def_log_file: /var/log/my-logging-file.log syslog_fix_perms: syslog:root +# disable_dns_redirection_detection: disable the code that attempts +# to determine if DNS redirection is in use. +# default: false +disable_dns_redirection_detection: false + # you can set passwords for a user or multiple users # this is off by default. # to set the default user's password, use the 'password' option. ___ 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] ~rmccabe/cloud-init:bug1693251 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1693251 into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) Related bugs: Bug #1693251 in cloud-init: "cloud-init should configure networkmanager to not manage /etc/resolv.conf" https://bugs.launchpad.net/cloud-init/+bug/1693251 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/325325 In cases where the config json specifies nameserver entries, NetworkManager, if enabled, will clobber the /etc/resolv.conf that cloud-init has produced, which can break dns. If at least one interface is configured for dhcp, you might end up with a resolv.conf that doesn't function as intended, and if you don't have any interfaces that get dns from dhcp, NetworkManager could clobber resolv.conf with an empty file. This patch adds a mechanism for dropping additional configuration into /etc/NetworkManager/conf.d/. I figured at some point, somebody will need to set some other keypair to stop NetworkManager from misbehaving, so I added something for that instead of simply writing the particular 2 lines of config to fix the resolv.conf issue. This patch only writes out that configuration file if necessary (as opposed to creating an empty file when there is no config needed). I wasn't sure which was preferred, so if that's not ideal, I could write out the empty file for consistency. This patch will also write that config "(dns=none") out, too, for the specific problem noted in #1693251 LP: #1693251 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1693251 into cloud-init:master. diff --git a/cloudinit/distros/parsers/networkmanager_conf.py b/cloudinit/distros/parsers/networkmanager_conf.py new file mode 100644 index 000..ac51f12 --- /dev/null +++ b/cloudinit/distros/parsers/networkmanager_conf.py @@ -0,0 +1,23 @@ +# Copyright (C) 2017 Red Hat, Inc. +# +# Author: Ryan McCabe <rmcc...@redhat.com> +# +# This file is part of cloud-init. See LICENSE file for license information. + +import configobj + +# This module is used to set additional NetworkManager configuration +# in /etc/NetworkManager/conf.d +# + + +class NetworkManagerConf(configobj.ConfigObj): +def __init__(self, contents): +configobj.ConfigObj.__init__(self, contents, + interpolation=False, + write_empty_values=False) + +def set_section_keypair(self, section_name, key, value): +if section_name not in self.sections: +self.main[section_name] = {} +self.main[section_name] = {key: value} diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index f7d4548..b5c90a6 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -5,6 +5,7 @@ import re import six +from cloudinit.distros.parsers import networkmanager_conf from cloudinit.distros.parsers import resolv_conf from cloudinit import util @@ -252,6 +253,9 @@ class Renderer(renderer.Renderer): self.netrules_path = config.get( 'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules') self.dns_path = config.get('dns_path', 'etc/resolv.conf') +nm_conf_path = 'etc/NetworkManager/conf.d/99-cloud-init.conf' +self.networkmanager_conf_path = config.get('networkmanager_conf_path', + nm_conf_path) @classmethod def _render_iface_shared(cls, iface, iface_cfg): @@ -447,6 +451,21 @@ class Renderer(renderer.Renderer): content.add_search_domain(searchdomain) return "\n".join([_make_header(';'), str(content)]) +@staticmethod +def _render_networkmanager_conf(network_state): +content = networkmanager_conf.NetworkManagerConf("") + +# If DNS server information is provided, configure +# NetworkManager to not manage dns, so that /etc/resolv.conf +# does not get clobbered. +if network_state.dns_nameservers: +content.set_section_keypair('main', 'dns', 'none') + +if len(content) == 0: +return None +out = "".join([_make_header(), "\n", "\n".join(content.write()), "\n"]) +return out + @classmethod def _render_bridge_interfaces(cls, network_state, iface_contents): bridge_filter = renderer.filter_by_type('bridge') @@ -507,6 +526,12 @@ class Renderer(renderer.Renderer): resolv_content = self._render_dns(network_state, existing_dns_path=dns_path) 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) +nm_conf_con
Re: [Cloud-init-dev] [Merge] ~rmccabe/cloud-init:bug1693251 into cloud-init:master
I submitted the form a few minutes ago. Let me know if there are any issues with it. Thanks, Ryan -- https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/325239 Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1693251 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] ~rmccabe/cloud-init:bug1693251 into cloud-init:master
Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1693251 into cloud-init:master. Requested reviews: cloud-init commiters (cloud-init-dev) Related bugs: Bug #1693251 in cloud-init: "cloud-init should configure networkmanager to not manage /etc/resolv.conf" https://bugs.launchpad.net/cloud-init/+bug/1693251 For more details, see: https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/325239 LP: #1693251 In cases where the config json specifies nameserver entries, NetworkManager, if enabled, will clobber the /etc/resolv.conf that cloud-init has produced, which can break dns. If at least one interface is configured for dhcp, you might end up with a resolv.conf that doesn't function as intended, and if you don't have any interfaces that get dns from dhcp, NetworkManager could clobber resolv.conf with an empty file. This patch adds a mechanism for dropping additional configuration into /etc/NetworkManager/conf.d/. I figured at some point, somebody will need to set some other keypair to stop NetworkManager from misbehaving, so I added something for that instead of simply writing the particular 2 lines of config to fix the resolv.conf issue. This patch only writes out that configuration file if necessary (as opposed to creating an empty file when there is no config needed). I wasn't sure which was preferred, so if that's not ideal, I could write out the empty file for consistency. This patch will also write that config "(dns=none") out, too, for the specific problem noted in #1693251 -- Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1693251 into cloud-init:master. diff --git a/cloudinit/distros/parsers/networkmanager_conf.py b/cloudinit/distros/parsers/networkmanager_conf.py new file mode 100644 index 000..aa57582 --- /dev/null +++ b/cloudinit/distros/parsers/networkmanager_conf.py @@ -0,0 +1,25 @@ +# Copyright (C) 2017 Red Hat, Inc. +# +# Author: Ryan McCabe <rmcc...@redhat.com> +# +# This file is part of cloud-init. See LICENSE file for license information. + +import six +from six import StringIO + +import configobj + +# This module is used to set additional NetworkManager configuration +# in /etc/NetworkManager/conf.d +# + +class NetworkManagerConf(configobj.ConfigObj): +def __init__(self, contents): +configobj.ConfigObj.__init__(self, contents, + interpolation=False, + write_empty_values=False) + +def set_section_keypair(self, section_name, key, value): +if not section_name in self.sections: +self.main[section_name] = {} +self.main[section_name] = {key: value} diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index 58c5713..6659d3b 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -6,6 +6,7 @@ import re import six from cloudinit.distros.parsers import resolv_conf +from cloudinit.distros.parsers import networkmanager_conf from cloudinit import util from . import renderer @@ -252,6 +253,9 @@ class Renderer(renderer.Renderer): self.netrules_path = config.get( 'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules') self.dns_path = config.get('dns_path', 'etc/resolv.conf') +nm_conf_path = 'etc/NetworkManager/conf.d/99-cloud-init.conf' +self.networkmanager_conf_path = config.get('networkmanager_conf_path', + nm_conf_path) @classmethod def _render_iface_shared(cls, iface, iface_cfg): @@ -445,6 +449,20 @@ class Renderer(renderer.Renderer): content.add_search_domain(searchdomain) return "\n".join([_make_header(';'), str(content)]) +@staticmethod +def _render_networkmanager_conf(network_state): +content = networkmanager_conf.NetworkManagerConf("") + +# If DNS server information is provided, configure +# NetworkManager to not manage dns, so that /etc/resolv.conf +# does not get clobbered. +if network_state.dns_nameservers: +content.set_section_keypair('main', 'dns', 'none') + +if len(content) == 0: +return None +return "".join([_make_header(), "\n", "\n".join(content.write()), "\n"]) + @classmethod def _render_bridge_interfaces(cls, network_state, iface_contents): bridge_filter = renderer.filter_by_type('bridge') @@ -505,6 +523,12 @@ class Renderer(renderer.Renderer): resolv_content = self._render_dns(network_state, existing_dns_path=dns_path) util.write_file(dns_path, resolv_content, file_mode) +if self.networkmanager_conf_path: +nm_conf_path = util.target_path(target, +self.net