diff --git a/kuryr_libnetwork/controllers.py b/kuryr_libnetwork/controllers.py index e3e79b45..73b39963 100644 --- a/kuryr_libnetwork/controllers.py +++ b/kuryr_libnetwork/controllers.py @@ -118,8 +118,7 @@ def get_driver(port): if driver is None: raise exceptions.KuryrException( "No port driver available for VNIC type %s" % vnic_type) - else: - return driver + return driver def _cache_default_subnetpool_ids(app): @@ -1879,7 +1878,9 @@ def ipam_release_address(): app.neutron.delete_port(port['id']) elif tags and const.KURYR_EXISTING_NEUTRON_PORT in tags: updated_port = {'name': '', 'device_owner': '', - 'device_id': '', 'binding:host_id': ''} + 'binding:host_id': ''} + if port['name'].startswith(port['device_id']): + updated_port["device_id"] = '' app.neutron.update_port(port['id'], {'port': updated_port}) _neutron_port_remove_tag(port['id'], const.KURYR_EXISTING_NEUTRON_PORT) diff --git a/kuryr_libnetwork/tests/unit/test_kuryr_ipam.py b/kuryr_libnetwork/tests/unit/test_kuryr_ipam.py index 2bfbaade..31c54d22 100644 --- a/kuryr_libnetwork/tests/unit/test_kuryr_ipam.py +++ b/kuryr_libnetwork/tests/unit/test_kuryr_ipam.py @@ -1562,7 +1562,10 @@ class TestKuryrIpam(base.TestKuryrBase): mock_list_subnets.assert_called_with( subnetpool_id=fake_kuryr_subnetpool_id) mock_list_ports.assert_called() - mock_update_port.assert_called() + expect_updated_port = {'name': '', 'device_owner': '', + 'device_id': '', 'binding:host_id': ''} + mock_update_port.assert_called_with(fake_port['port']['id'], + {'port': expect_updated_port}) mock_delete_port.assert_not_called() mock_remove_tag.assert_called_with('ports', fake_port['port']['id'],