Don't remove ip addresses if not master

When setting --admin-state-up=False on an HA router with a gateway set,
standby nodes don't have any ip addresses set on the devices (although
the devices themselves are present). In such cases, Neutron should not
try to un-set those ip addresses before deleting the device itself.

Closes-bug: #1505203
Change-Id: I5df04b2ed1dc08286f6c467111c61c7f97643d66
This commit is contained in:
John Schwarz 2015-10-12 15:53:49 +03:00 committed by Miguel Angel Ajo
parent 5cdab68528
commit b8f17bac76
2 changed files with 21 additions and 2 deletions

View File

@ -366,8 +366,15 @@ class HaRouter(router.RouterInfo):
def external_gateway_removed(self, ex_gw_port, interface_name):
self._clear_vips(interface_name)
super(HaRouter, self).external_gateway_removed(ex_gw_port,
interface_name)
if self.ha_state == 'master':
super(HaRouter, self).external_gateway_removed(ex_gw_port,
interface_name)
else:
# We are not the master node, so no need to delete ip addresses.
self.driver.unplug(interface_name,
bridge=self.agent_conf.external_network_bridge,
namespace=self.ns_name,
prefix=router.EXTERNAL_DEV_PREFIX)
def delete(self, agent):
super(HaRouter, self).delete(agent)

View File

@ -790,6 +790,18 @@ class L3AgentTestCase(L3AgentTestFramework):
self.addCleanup(netcat.stop_processes)
self.assertTrue(netcat.test_connectivity())
def test_delete_external_gateway_on_standby_router(self):
router_info = self.generate_router_info(enable_ha=True)
router = self.manage_router(self.agent, router_info)
self.fail_ha_router(router)
utils.wait_until_true(lambda: router.ha_state == 'backup')
# The purpose of the test is to simply make sure no exception is raised
port = router.get_ex_gw_port()
interface_name = router.get_external_device_name(port['id'])
router.external_gateway_removed(port, interface_name)
class L3HATestFramework(L3AgentTestFramework):