Remove race between sync_pools and _get_port_from_pool
This patch ensures that if there is an attempt to allocate a
port during the pod creation but the kuryr-controller has not yet
finished its sync_pool initialization, a ResourceNotReady exception
will be triggered and the port allocation attempt will be retried
later
Closes-Bug:
@@ -294,7 +294,7 @@ class NeutronVIFPool(BaseVIFPool):
def _get_port_from_pool(self, pool_key, pod, subnets):
try:
port_id = self._available_ports_pools[pool_key].pop()
- except IndexError:
+ except (IndexError, AttributeError):
raise exceptions.ResourceNotReady(pod)
if config.CONF.kubernetes.port_debug:
neutron = clients.get_neutron_client()
@@ -456,7 +456,7 @@ class NestedVIFPool(BaseVIFPool):
def _get_port_from_pool(self, pool_key, pod, subnets):
try:
port_id = self._available_ports_pools[pool_key].pop()
- except IndexError:
+ except (IndexError, AttributeError):
raise exceptions.ResourceNotReady(pod)
if config.CONF.kubernetes.port_debug:
neutron = clients.get_neutron_client()
