Do not send status update in case of IpAddressAlreadyAllocated
If IpAddressAlreadyAllocated is raised and the created VIP with the same IP address allocated is not owned by LB that we're trying to create, we should raise DriverError instead passing the status update to Octavia API. Change-Id: Id0dc8a478b903b80cf8afdfa3d2b23e90d22e112 Closes-Bug: 1882724
This commit is contained in:
parent
28c311ccd7
commit
ac4d0272a8
|
@ -368,5 +368,10 @@ class OvnProviderDriver(driver_base.ProviderDriver):
|
|||
vip_dict[constants.VIP_ADDRESS] = (
|
||||
port['fixed_ips'][0]['ip_address'])
|
||||
except Exception as e:
|
||||
raise driver_exceptions.DriverError(e)
|
||||
kwargs = {}
|
||||
if hasattr(e, 'message'):
|
||||
kwargs = {'user_fault_string': e.message,
|
||||
'operator_fault_string': e.message}
|
||||
raise driver_exceptions.DriverError(
|
||||
**kwargs)
|
||||
return vip_dict
|
||||
|
|
|
@ -1675,7 +1675,7 @@ class OvnProviderHelper(object):
|
|||
neutron_client = clients.get_neutron_client()
|
||||
try:
|
||||
return neutron_client.create_port(port)
|
||||
except n_exc.IpAddressAlreadyAllocatedClient:
|
||||
except n_exc.IpAddressAlreadyAllocatedClient as e:
|
||||
# Sometimes the VIP is already created (race-conditions)
|
||||
# Lets get the it from Neutron API.
|
||||
ports = neutron_client.list_ports(
|
||||
|
@ -1684,13 +1684,7 @@ class OvnProviderHelper(object):
|
|||
if not ports['ports']:
|
||||
LOG.error('Cannot create/get LoadBalancer VIP port with '
|
||||
'fixed IP: %s', vip_d[constants.VIP_ADDRESS])
|
||||
status = {
|
||||
constants.LOADBALANCERS: [{
|
||||
constants.ID: lb_id,
|
||||
constants.PROVISIONING_STATUS: constants.ERROR,
|
||||
constants.OPERATING_STATUS: constants.ERROR}]}
|
||||
self._update_status_to_octavia(status)
|
||||
return
|
||||
raise e
|
||||
# there should only be one port returned
|
||||
port = ports['ports'][0]
|
||||
LOG.debug('VIP Port already exists, uuid: %s', port['id'])
|
||||
|
|
|
@ -2255,22 +2255,19 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
|
|||
net_cli.return_value.list_ports.return_value = {
|
||||
'ports': []}
|
||||
self.vip_dict['vip_address'] = '10.1.10.1'
|
||||
ret = self.helper.create_vip_port(
|
||||
self.assertRaises(
|
||||
n_exc.IpAddressAlreadyAllocatedClient,
|
||||
self.helper.create_vip_port,
|
||||
self.project_id,
|
||||
self.loadbalancer_id,
|
||||
self.vip_dict)
|
||||
self.assertIsNone(ret)
|
||||
expected_call = [
|
||||
mock.call().list_ports(
|
||||
network_id='%s' % self.vip_dict['vip_network_id'],
|
||||
name='%s%s' % (ovn_const.LB_VIP_PORT_PREFIX,
|
||||
self.loadbalancer_id))]
|
||||
net_cli.assert_has_calls(expected_call)
|
||||
self.helper._update_status_to_octavia.assert_called_once_with(
|
||||
{'loadbalancers':
|
||||
[{'id': self.loadbalancer_id,
|
||||
'provisioning_status': 'ERROR',
|
||||
'operating_status': 'ERROR'}]})
|
||||
self.helper._update_status_to_octavia.assert_not_called()
|
||||
|
||||
def test_get_pool_member_id(self):
|
||||
ret = self.helper.get_pool_member_id(
|
||||
|
|
Loading…
Reference in New Issue