Merge "Add debug information to AutoScheduler and BaseScheduler"

This commit is contained in:
Zuul 2019-05-30 17:46:56 +00:00 committed by Gerrit Code Review
commit 8a02675582
2 changed files with 13 additions and 0 deletions

@ -17,8 +17,11 @@ import abc
from operator import attrgetter
import random
from oslo_log import log as logging
import six
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BaseScheduler(object):
@ -48,6 +51,11 @@ class BaseScheduler(object):
hosted_agents, num_agents)
# bind the resource to the agents
self.resource_filter.bind(context, chosen_agents, resource['id'])
debug_data = ['(%s, %s, %s)' %
(agent['agent_type'], agent['host'], resource['id'])
for agent in chosen_agents]
LOG.debug('Resources bound (agent type, host, resource id): %s',
', '.join(debug_data))
return chosen_agents

@ -90,8 +90,13 @@ class AutoScheduler(object):
bindings_to_add.append((dhcp_agent, net_id))
# do it outside transaction so particular scheduling results don't
# make other to fail
debug_data = []
for agent, net_id in bindings_to_add:
self.resource_filter.bind(context, [agent], net_id)
debug_data.append('(%s, %s, %s)' % (agent['agent_type'],
agent['host'], net_id))
LOG.debug('Resources bound (agent type, host, resource id): %s',
', '.join(debug_data))
return True