Fix: Skip rescheduling networks if no DHCP agents available
This fixes commit 1318437a0c
which has inaccurate check for dead agents: in a case where
there is only one network scheduled to a subset of dhcp agents,
number of all dhcp agents will be not equal to the number of
dead binded agents
The unit test is updated to cover the described case.
Closes-Bug: #1461714
Change-Id: I1c9501316c931293aa8ba755a98779a7da27578d
This commit is contained in:
parent
c584417967
commit
6e3817433e
|
@ -273,10 +273,11 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
|
|||
try:
|
||||
dead_bindings = [b for b in
|
||||
self._filter_bindings(context, down_bindings)]
|
||||
dead_agents = set([b.dhcp_agent_id for b in dead_bindings])
|
||||
agents = self.get_agents_db(
|
||||
context, {'agent_type': [constants.AGENT_TYPE_DHCP]})
|
||||
if len(agents) == len(dead_agents):
|
||||
active_agents = [agent for agent in agents if
|
||||
self.is_eligible_agent(context, True, agent)]
|
||||
if not active_agents:
|
||||
LOG.warn(_LW("No DHCP agents available, "
|
||||
"skipping rescheduling"))
|
||||
return
|
||||
|
|
|
@ -260,7 +260,7 @@ class TestNetworksFailover(TestDhcpSchedulerBaseTestCase,
|
|||
self.remove_networks_from_down_agents()
|
||||
|
||||
def test_reschedule_doesnt_occur_if_no_agents(self):
|
||||
agents = self._create_and_set_agents_down(['host-a'], 1)
|
||||
agents = self._create_and_set_agents_down(['host-a', 'host-b'], 2)
|
||||
self._test_schedule_bind_network([agents[0]], self.network_id)
|
||||
with mock.patch.object(
|
||||
self, 'remove_network_from_dhcp_agent') as rn:
|
||||
|
|
Loading…
Reference in New Issue