diff --git a/kuryr_kubernetes/controller/drivers/vif_pool.py b/kuryr_kubernetes/controller/drivers/vif_pool.py index daf1ae3e9..052f9734f 100644 --- a/kuryr_kubernetes/controller/drivers/vif_pool.py +++ b/kuryr_kubernetes/controller/drivers/vif_pool.py @@ -1138,6 +1138,7 @@ class NestedVIFPool(BaseVIFPool): "pools.") raise exceptions.ResourceNotReady(net_id) + epool = eventlet.GreenPool(constants.LEFTOVER_RM_POOL_SIZE) ports_to_remove = [] # NOTE(ltomasbo): Note the pods should already be deleted, but their @@ -1160,7 +1161,7 @@ class NestedVIFPool(BaseVIFPool): except (os_exc.SDKException, os_exc.HttpException): LOG.exception('Error removing subports from trunk: %s', trunk_id) - continue + raise exceptions.ResourceNotReady(net_id) for port_id in ports_id: try: @@ -1178,9 +1179,14 @@ class NestedVIFPool(BaseVIFPool): except KeyError: pass - if not c_utils.delete_ports(ports_to_remove): - LOG.error('Some ports failed to be deleted.') - raise exceptions.ResourceNotReady(net_id) + # Parallelize Ports deletion. At this point the Ports + # should have been detatched from Trunk and if not operation + # will be retried + for result in epool.imap(c_utils.delete_neutron_port, ports_to_remove): + if result: + LOG.error('During Neutron port deletion an error occured: %s', + result) + raise exceptions.ResourceNotReady(net_id) class MultiVIFPool(base.VIFPoolDriver): diff --git a/kuryr_kubernetes/tests/unit/controller/drivers/test_vif_pool.py b/kuryr_kubernetes/tests/unit/controller/drivers/test_vif_pool.py index 613b8d8ad..fe264788e 100644 --- a/kuryr_kubernetes/tests/unit/controller/drivers/test_vif_pool.py +++ b/kuryr_kubernetes/tests/unit/controller/drivers/test_vif_pool.py @@ -1757,7 +1757,8 @@ class NestedVIFPool(test_base.TestCase): m_driver._drv_vif._remove_subports.assert_called_once_with(trunk_id, [port_id]) m_driver._drv_vif._release_vlan_id.assert_called_once_with(vlan_id) - m_pool.imap.assert_called_once_with(utils.delete_port, [port_id]) + m_pool.imap.assert_called_once_with(utils.delete_neutron_port, + [port_id]) def test_delete_network_pools_not_ready(self): cls = vif_pool.NestedVIFPool @@ -1804,7 +1805,8 @@ class NestedVIFPool(test_base.TestCase): m_driver._get_pool_key_net.return_value = net_id m_driver._drv_vif._remove_subports.side_effect = os_exc.SDKException - cls.delete_network_pools(m_driver, net_id) + self.assertRaises(exceptions.ResourceNotReady, + cls.delete_network_pools, m_driver, net_id) m_driver._trigger_return_to_pool.assert_called_once() m_driver._get_pool_key_net.assert_called_once() @@ -1850,4 +1852,5 @@ class NestedVIFPool(test_base.TestCase): m_driver._drv_vif._remove_subports.assert_called_once_with(trunk_id, [port_id]) m_driver._drv_vif._release_vlan_id.assert_not_called() - m_pool.imap.assert_called_once_with(utils.delete_port, [port_id]) + m_pool.imap.assert_called_once_with(utils.delete_neutron_port, + [port_id])