Browse Source

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.

Cherry-picked from OVN-Octavia-Provider: https://review.opendev.org/#/c/734634/
Change-Id: Id0dc8a478b903b80cf8afdfa3d2b23e90d22e112
Closes-Bug: 1882724
(cherry picked from commit 2448c4925b7c2b2e4f4287a14bc67fa5e8360002)
changes/72/734772/1
Maciej Jozefczyk 1 month ago
parent
commit
18091f0ba1
2 changed files with 12 additions and 15 deletions
  1. +8
    -8
      networking_ovn/octavia/ovn_driver.py
  2. +4
    -7
      networking_ovn/tests/unit/octavia/test_ovn_driver.py

+ 8
- 8
networking_ovn/octavia/ovn_driver.py View File

@@ -1803,7 +1803,7 @@ class OvnProviderHelper(object):
network_driver = get_network_driver()
try:
return network_driver.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 = network_driver.neutron_client.list_ports(
@@ -1812,12 +1812,7 @@ class OvnProviderHelper(object):
if not ports['ports']:
LOG.error('Cannot create/get LoadBalancer VIP port with '
'fixed IP: %s', vip_d['vip_address'])
status = {'loadbalancers': [{
"id": lb_id,
"provisioning_status": constants.ERROR,
"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'])
@@ -2274,5 +2269,10 @@ class OvnProviderDriver(driver_base.ProviderDriver):
vip_dict['vip_port_id'] = port['id']
vip_dict['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

+ 4
- 7
networking_ovn/tests/unit/octavia/test_ovn_driver.py View File

@@ -2810,22 +2810,19 @@ class TestOvnProviderHelper(TestOvnOctaviaBase):
net_dr.return_value.neutron_client.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().neutron_client.list_ports(
network_id='%s' % self.vip_dict['vip_network_id'],
name='%s%s' % (ovn_const.LB_VIP_PORT_PREFIX,
self.loadbalancer_id))]
net_dr.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…
Cancel
Save