Fix bug in "Minimum necessary upgrades for solver scheduler to pass tests in kilo"
This removes some incorrect codes in previous commit. Change-Id: I5a94f8c6b8b8b743842df8122d425c1ddfb87161
This commit is contained in:
parent
336b0388e3
commit
d0e3aa654c
|
@ -52,40 +52,6 @@ class ConstraintSolverScheduler(filter_scheduler.FilterScheduler):
|
||||||
self.hosts_solver = importutils.import_object(
|
self.hosts_solver = importutils.import_object(
|
||||||
CONF.solver_scheduler.scheduler_host_solver)
|
CONF.solver_scheduler.scheduler_host_solver)
|
||||||
|
|
||||||
def _setup_instance_group(self, context, filter_properties):
|
|
||||||
"""Update filter_properties with server group info.
|
|
||||||
|
|
||||||
:returns: True if filter_properties has been updated, False if not.
|
|
||||||
"""
|
|
||||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
|
||||||
group_hint = scheduler_hints.get('group', None)
|
|
||||||
if not group_hint:
|
|
||||||
return False
|
|
||||||
|
|
||||||
group = objects.InstanceGroup.get_by_hint(context, group_hint)
|
|
||||||
policies = set(('anti-affinity', 'affinity'))
|
|
||||||
if not any((policy in policies) for policy in group.policies):
|
|
||||||
return False
|
|
||||||
|
|
||||||
if ('affinity' in group.policies and
|
|
||||||
not self._supports_affinity):
|
|
||||||
msg = _("ServerGroupAffinityConstraint not configured")
|
|
||||||
LOG.error(msg)
|
|
||||||
raise exception.NoValidHost(reason=msg)
|
|
||||||
if ('anti-affinity' in group.policies and
|
|
||||||
not self._supports_anti_affinity):
|
|
||||||
msg = _("ServerGroupAntiAffinityConstraint not configured")
|
|
||||||
LOG.error(msg)
|
|
||||||
raise exception.NoValidHost(reason=msg)
|
|
||||||
|
|
||||||
filter_properties.setdefault('group_hosts', set())
|
|
||||||
user_hosts = set(filter_properties['group_hosts'])
|
|
||||||
group_hosts = set(group.get_hosts(context))
|
|
||||||
filter_properties['group_hosts'] = user_hosts | group_hosts
|
|
||||||
filter_properties['group_policies'] = group.policies
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _schedule(self, context, request_spec, filter_properties):
|
def _schedule(self, context, request_spec, filter_properties):
|
||||||
"""Returns a list of hosts that meet the required specs,
|
"""Returns a list of hosts that meet the required specs,
|
||||||
ordered by their fitness.
|
ordered by their fitness.
|
||||||
|
@ -93,8 +59,6 @@ class ConstraintSolverScheduler(filter_scheduler.FilterScheduler):
|
||||||
instance_type = request_spec.get("instance_type", None)
|
instance_type = request_spec.get("instance_type", None)
|
||||||
instance_uuids = request_spec.get("instance_uuids", None)
|
instance_uuids = request_spec.get("instance_uuids", None)
|
||||||
|
|
||||||
self._setup_instance_group(context, filter_properties)
|
|
||||||
|
|
||||||
config_options = self._get_configuration_options()
|
config_options = self._get_configuration_options()
|
||||||
|
|
||||||
if instance_uuids:
|
if instance_uuids:
|
||||||
|
|
Loading…
Reference in New Issue