Browse Source

Ensure 'port' is up2date after binding:host_id

On neutron routed provider networks IP allocation is
deferred until 'binding:host_id' is set. When ironic
creates neutron ports it first creates the port, then
updates the port setting binding information.

When using IPv6 networking ironic adds additional address
allocations to ensure network chain-booting will succeed.
When address allocation is deferred on port create ironic
cannot detect that IPv6 is used and does not add the
required additional addresses.

This change ensures the 'port' object is updated after the
port update setting the port binding required for neutron
to allocate the address. This allows ironic to correctly
detect IPv6 is used, and it will add the required IP
address allocations.

Story: 2009773
Task: 44254
Change-Id: I863dd4ab9615a9ce3b3dcb8798af674ac9966bf2
(cherry picked from commit 3404dc913e)
changes/65/824165/1 16.0.4
Harald Jensås 4 months ago
parent
commit
87f15ec6e7
  1. 3
      ironic/common/neutron.py
  2. 5
      ironic/tests/unit/common/test_neutron.py
  3. 6
      releasenotes/notes/fix-ipv6-provisioning-routed-provider-network-bbd0c46559f618ac.yaml

3
ironic/common/neutron.py

@ -344,7 +344,8 @@ def add_ports_to_network(task, network_uuid, security_groups=None):
wait_for_host_agent(
client, update_port_attrs['binding:host_id'])
port = client.create_port(**port_attrs)
update_neutron_port(task.context, port.id, update_port_attrs)
port = update_neutron_port(task.context, port.id,
update_port_attrs)
if CONF.neutron.dhcpv6_stateful_address_count > 1:
_add_ip_addresses_for_ipv6_stateful(task.context, port, client)
if is_smart_nic:

5
ironic/tests/unit/common/test_neutron.py

@ -289,11 +289,13 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
fixed_ips=[])
self.client_mock.create_port.side_effect = [self.neutron_port,
neutron_port2]
update_mock.side_effect = [self.neutron_port, neutron_port2]
expected = {port.uuid: self.neutron_port.id,
port2.uuid: neutron_port2.id}
else:
self.client_mock.create_port.return_value = self.neutron_port
update_mock.return_value = self.neutron_port
expected = {port.uuid: self.neutron_port['id']}
with task_manager.acquire(self.context, self.node.uuid) as task:
@ -457,6 +459,7 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
vpi_mock.return_value = True
# Ensure we can create ports
self.client_mock.create_port.return_value = self.neutron_port
update_mock.return_value = self.neutron_port
expected = {port.uuid: self.neutron_port.id}
with task_manager.acquire(self.context, self.node.uuid) as task:
ports = neutron.add_ports_to_network(task, self.network_uuid)
@ -491,6 +494,7 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
)
self.client_mock.create_port.side_effect = [
self.neutron_port, openstack_exc.OpenStackCloudException]
update_mock.return_value = self.neutron_port
with task_manager.acquire(self.context, self.node.uuid) as task:
neutron.add_ports_to_network(task, self.network_uuid)
self.assertIn("Could not create neutron port for node's",
@ -988,6 +992,7 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
# Ensure we can create ports
self.client_mock.create_port.return_value = self.neutron_port
update_mock.return_value = self.neutron_port
expected = {port.uuid: self.neutron_port.id}
with task_manager.acquire(self.context, self.node.uuid) as task:
ports = neutron.add_ports_to_network(task, self.network_uuid)

6
releasenotes/notes/fix-ipv6-provisioning-routed-provider-network-bbd0c46559f618ac.yaml

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed an issue where provisioning/cleaning would fail on IPv6 routed provider
networks. See bug:
`2009773 <https://storyboard.openstack.org/#!/story/2009773>`_.
Loading…
Cancel
Save