From 2fde1940b5a5a6624ed7a2dadf609eb2a80530cd Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 13 Jun 2019 16:43:00 -0700 Subject: [PATCH] Remove ipxe tags when ipx6 is in use. Turns out the dhcp server doesn't always do the right thing and our duplicated tags seem to create confusion. So lets remove them so ipxe6 will work. Change-Id: I446cb814ae41cfd1e9a4ed45f27dac17e9b5bb61 Story: 2005885 Task: 33734 --- ironic/common/pxe_utils.py | 29 ++++++++++--------- ironic/tests/unit/common/test_pxe_utils.py | 14 +-------- ...-ipxe-tags-with-ipv6-cf4b7937c27590d6.yaml | 6 ++++ 3 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 releasenotes/notes/remove-ipxe-tags-with-ipv6-cf4b7937c27590d6.yaml diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index 901d81d912..e6b2586d93 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -470,19 +470,22 @@ def dhcp_options_for_instance(task, ipxe_enabled=False, url_boot=False): # added in the Stein cycle which identifies the iPXE User-Class # directly and is only sent in DHCPv6. - # NOTE(TheJulia): Lets send both, let neutron tag/sort it out as - # an ip_version field is also transmitted. Plus, given the - # semi-obscure nature of this, being more verbose and letting - # the DHCP server do the best thing possible is likely the best - # course of action. - dhcp_opts.append({'opt_name': "tag:!ipxe,%s" % boot_file_param, - 'opt_value': boot_file}) - dhcp_opts.append({'opt_name': "tag:!ipxe6,%s" % boot_file_param, - 'opt_value': boot_file}) - dhcp_opts.append({'opt_name': "tag:ipxe,%s" % boot_file_param, - 'opt_value': ipxe_script_url}) - dhcp_opts.append({'opt_name': "tag:ipxe6,%s" % boot_file_param, - 'opt_value': ipxe_script_url}) + if ip_version != 6: + dhcp_opts.append( + {'opt_name': "tag:!ipxe,%s" % boot_file_param, + 'opt_value': boot_file} + ) + dhcp_opts.append( + {'opt_name': "tag:ipxe,%s" % boot_file_param, + 'opt_value': ipxe_script_url} + ) + else: + dhcp_opts.append( + {'opt_name': "tag:!ipxe6,%s" % boot_file_param, + 'opt_value': boot_file}) + dhcp_opts.append( + {'opt_name': "tag:ipxe6,%s" % boot_file_param, + 'opt_value': ipxe_script_url}) else: # !175 == non-iPXE. # http://ipxe.org/howto/dhcpd#ipxe-specific_options diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 6f1372ee01..b082a059a2 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -857,15 +857,9 @@ class TestPXEUtils(db_base.DbTestCase): self.config(dhcp_provider='neutron', group='dhcp') if ip_version == 6: # Boot URL variable set from prior test of isc parameters. - expected_info = [{'opt_name': 'tag:!ipxe,59', + expected_info = [{'opt_name': 'tag:!ipxe6,59', 'opt_value': 'tftp://[ff80::1]/fake-bootfile', 'ip_version': ip_version}, - {'opt_name': 'tag:!ipxe6,59', - 'opt_value': 'tftp://[ff80::1]/fake-bootfile', - 'ip_version': ip_version}, - {'opt_name': 'tag:ipxe,59', - 'opt_value': expected_boot_script_url, - 'ip_version': ip_version}, {'opt_name': 'tag:ipxe6,59', 'opt_value': expected_boot_script_url, 'ip_version': ip_version}] @@ -874,9 +868,6 @@ class TestPXEUtils(db_base.DbTestCase): expected_info = [{'opt_name': 'tag:!ipxe,67', 'opt_value': boot_file, 'ip_version': ip_version}, - {'opt_name': 'tag:!ipxe6,67', - 'opt_value': boot_file, - 'ip_version': ip_version}, {'opt_name': '66', 'opt_value': '192.0.2.1', 'ip_version': ip_version}, @@ -886,9 +877,6 @@ class TestPXEUtils(db_base.DbTestCase): {'opt_name': 'tag:ipxe,67', 'opt_value': expected_boot_script_url, 'ip_version': ip_version}, - {'opt_name': 'tag:ipxe6,67', - 'opt_value': expected_boot_script_url, - 'ip_version': ip_version}, {'opt_name': 'server-ip-address', 'opt_value': '192.0.2.1', 'ip_version': ip_version}] diff --git a/releasenotes/notes/remove-ipxe-tags-with-ipv6-cf4b7937c27590d6.yaml b/releasenotes/notes/remove-ipxe-tags-with-ipv6-cf4b7937c27590d6.yaml new file mode 100644 index 0000000000..5e4876212d --- /dev/null +++ b/releasenotes/notes/remove-ipxe-tags-with-ipv6-cf4b7937c27590d6.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes the duplication of the "ipxe" tag when using IPv6, which leads to + the dhcp server possibly returning an incorrect response to the DHCPv6 + client.