Merge "Ignore a port not found when deleting an LB"

This commit is contained in:
Zuul 2018-07-10 17:14:21 +00:00 committed by Gerrit Code Review
commit 625ac5b69e
2 changed files with 20 additions and 2 deletions

View File

@ -266,8 +266,15 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
'port', {}).get('security_groups', [])
if sec_grp_id in sec_grps:
sec_grps.remove(sec_grp_id)
port_update = {'port': {'security_groups': sec_grps}}
self.neutron_client.update_port(port.id, port_update)
port_update = {'port': {'security_groups': sec_grps}}
try:
self.neutron_client.update_port(port.id,
port_update)
except neutron_client_exceptions.PortNotFoundClient:
LOG.warning('Unable to update port information '
'for port %s. Continuing to delete '
'the security group since port not '
'found', port.id)
try:
self._delete_vip_security_group(sec_grp_id)

View File

@ -252,6 +252,17 @@ class TestAllowedAddressPairsDriver(base.TestCase):
show_port.side_effect = neutron_exceptions.PortNotFoundClient
self.driver.deallocate_vip(vip)
def test_deallocate_vip_when_port_not_found_for_update(self):
lb = dmh.generate_load_balancer_tree()
vip = data_models.Vip(port_id='1')
vip.load_balancer = lb
show_port = self.driver.neutron_client.show_port
show_port.return_value = {'port': {
'device_owner': allowed_address_pairs.OCTAVIA_OWNER}}
update_port = self.driver.neutron_client.update_port
update_port.side_effect = neutron_exceptions.PortNotFoundClient
self.driver.deallocate_vip(vip)
def test_deallocate_vip_when_port_not_owned_by_octavia(self):
lb = dmh.generate_load_balancer_tree()
lb.vip.load_balancer = lb