Merge "Check for l3 agents count before router update"

This commit is contained in:
Jenkins 2016-09-27 02:23:04 +00:00 committed by Gerrit Code Review
commit 83284c4e24
2 changed files with 15 additions and 0 deletions

View File

@ -544,6 +544,12 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
msg = _('Cannot change HA attribute of active routers. Please '
'set router admin_state_up to False prior to upgrade.')
raise n_exc.BadRequest(resource='router', msg=msg)
if requested_ha_state:
# This will throw HANotEnoughAvailableAgents if there aren't
# enough l3 agents to handle this router.
self.get_number_of_agents_for_scheduling(context)
# set status to ALLOCATING so this router is no longer
# provided to agents while its interfaces are being re-configured.
# Keep in mind that if we want conversion to be hitless, this

View File

@ -394,6 +394,15 @@ class L3HATestCase(L3HATestFramework):
ha=True,
distributed=True)
def test_migrate_legacy_router_to_ha_not_enough_agents(self):
router = self._create_router(ha=False, distributed=False)
self.assertFalse(router['ha'])
self.assertFalse(router['distributed'])
helpers.set_agent_admin_state(self.agent2['id'], admin_state_up=False)
self.assertRaises(l3_ext_ha_mode.HANotEnoughAvailableAgents,
self._migrate_router, router['id'], ha=True)
def test_unbind_ha_router(self):
router = self._create_router()