Always return iterables in L3 get_candidates
The caller of this function expects iterables. Closes-Bug: #1494996 Change-Id: I3d103e63f4e127a77268502415c0ddb0d804b54a
This commit is contained in:
parent
2555663dfe
commit
d1d4de19d8
|
@ -174,12 +174,12 @@ class L3Scheduler(object):
|
|||
' by L3 agent %(agent_id)s',
|
||||
{'router_id': sync_router['id'],
|
||||
'agent_id': l3_agents[0]['id']})
|
||||
return
|
||||
return []
|
||||
|
||||
active_l3_agents = plugin.get_l3_agents(context, active=True)
|
||||
if not active_l3_agents:
|
||||
LOG.warn(_LW('No active L3 agents'))
|
||||
return
|
||||
return []
|
||||
new_l3agents = plugin.get_l3_agent_candidates(context,
|
||||
sync_router,
|
||||
active_l3_agents)
|
||||
|
|
|
@ -268,6 +268,17 @@ class L3SchedulerBaseTestCase(base.BaseTestCase):
|
|||
def test__bind_routers_ha_no_binding(self):
|
||||
self._test__bind_routers_ha(has_binding=False)
|
||||
|
||||
def test__get_candidates_iterable_on_early_returns(self):
|
||||
plugin = mock.MagicMock()
|
||||
# non-distributed router already hosted
|
||||
plugin.get_l3_agents_hosting_routers.return_value = [{'id': 'a1'}]
|
||||
router = {'distributed': False, 'id': 'falafel'}
|
||||
iter(self.scheduler._get_candidates(plugin, mock.MagicMock(), router))
|
||||
# distributed router but no agents
|
||||
router['distributed'] = True
|
||||
plugin.get_l3_agents.return_value = []
|
||||
iter(self.scheduler._get_candidates(plugin, mock.MagicMock(), router))
|
||||
|
||||
|
||||
class L3SchedulerBaseMixin(object):
|
||||
|
||||
|
|
Loading…
Reference in New Issue