Add log information in agent schedulers

Added log information about the hostable DHCP agents per network.
Added log information when an agent is declared "down" because the
heartbeat is too old.

Those log messages are included according to [1].

[1] https://bugs.launchpad.net/neutron/+bug/1799555/comments/8

Change-Id: I7b30499a86e5ae5de49813dfca01788fd5fce139
Related-Bug: #1799555
This commit is contained in:
Rodolfo Alonso Hernandez 2019-06-07 11:18:57 +00:00
parent fc5235c49c
commit d01a1deca9
2 changed files with 22 additions and 7 deletions

View File

@ -65,8 +65,14 @@ class AgentSchedulerDbMixin(agents_db.AgentDbMixin):
# filter is set, only agents which are 'up'
# (i.e. have a recent heartbeat timestamp)
# are eligible, even if active is False
return not agent_utils.is_agent_down(
agent['heartbeat_timestamp'])
if agent_utils.is_agent_down(agent['heartbeat_timestamp']):
LOG.warning('Agent %(agent)s is down. Type: %(type)s, host: '
'%(host)s, heartbeat: %(heartbeat)s',
{'agent': agent['id'], 'type': agent['agent_type'],
'host': agent['host'],
'heartbeat': agent['heartbeat_timestamp']})
return False
return True
def update_agent(self, context, id, agent):
original_agent = self.get_agent(context, id)

View File

@ -280,8 +280,17 @@ class DhcpFilter(base_resource_filter.BaseResourceFilter):
plugin, context, network, hostable_dhcp_agents)
if not hostable_dhcp_agents:
return {'n_agents': 0, 'hostable_agents': [],
'hosted_agents': hosted_agents}
n_agents = min(len(hostable_dhcp_agents), n_agents)
return {'n_agents': n_agents, 'hostable_agents': hostable_dhcp_agents,
'hosted_agents': hosted_agents}
result = {'n_agents': 0, 'hostable_agents': [],
'hosted_agents': hosted_agents}
else:
result = {'n_agents': min(len(hostable_dhcp_agents), n_agents),
'hostable_agents': hostable_dhcp_agents,
'hosted_agents': hosted_agents}
hostable_agents_ids = [a['id'] for a in result['hostable_agents']]
hosted_agents_ids = [a['id'] for a in result['hosted_agents']]
LOG.debug('Network hostable DHCP agents. Network: %(network)s, '
'hostable agents: %(hostable_agents)s, hosted agents: '
'%(hosted_agents)s', {'network': network['id'],
'hostable_agents': hostable_agents_ids,
'hosted_agents': hosted_agents_ids})
return result