Revert "Initial scheduler support for instance_groups"
This reverts commit b2c17ae891b12118b9d11bf0ecc44e77956715c8. While reviewing merged changes, I came across this one. It's using the conductor in a way that it shouldn't. The scheduler has db access, so there's no need to add the extra conductor overhead. The best thing to do here is to just revert for now, IMO. Change-Id: Iaa0d67df7bb84913784d925cffebcd5f252249ea
This commit is contained in:
@@ -94,14 +94,6 @@ def instance_update_db(context, instance_uuid, extra_values=None):
|
||||
values = {'host': None, 'node': None, 'scheduled_at': now}
|
||||
if extra_values:
|
||||
values.update(extra_values)
|
||||
# Get the instance_group if it exists. This will be written to the
|
||||
# system_metadata as it will be used when the VM is deleted
|
||||
system_metadata = extra_values.get('system_metadata', None)
|
||||
if system_metadata:
|
||||
instance_group = system_metadata.get('instance_group', None)
|
||||
if instance_group:
|
||||
conductor_api.instance_group_members_add(context,
|
||||
instance_group, [instance_uuid])
|
||||
|
||||
return db.instance_update(context, instance_uuid, values)
|
||||
|
||||
@@ -147,17 +139,15 @@ class Scheduler(object):
|
||||
for service in services
|
||||
if self.servicegroup_api.service_is_up(service)]
|
||||
|
||||
def instance_group_data(self, context, group_uuid):
|
||||
"""Return the the group data for the instance group."""
|
||||
def group_hosts(self, context, group):
|
||||
"""Return the list of hosts that have VM's from the group."""
|
||||
|
||||
return conductor_api.instance_group_get_all(context, group_uuid)
|
||||
|
||||
def instance_group_hosts(self, context, instance_group):
|
||||
"""Return the list of hosts that have VM's from the instance_group."""
|
||||
|
||||
instances = instance_group['instances']
|
||||
return [instance['host'] for instance in instances
|
||||
if instance.get('host') is not None]
|
||||
# The system_metadata 'group' will be filtered
|
||||
members = db.instance_get_all_by_filters(context,
|
||||
{'deleted': False, 'group': group})
|
||||
return [member['host']
|
||||
for member in members
|
||||
if member.get('host') is not None]
|
||||
|
||||
def schedule_prep_resize(self, context, image, request_spec,
|
||||
filter_properties, instance, instance_type,
|
||||
|
||||
@@ -173,11 +173,11 @@ class FilterScheduler(driver.Scheduler):
|
||||
|
||||
# Update the metadata if necessary
|
||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
||||
group_uuid = scheduler_hints.get('instance_group', None)
|
||||
group = scheduler_hints.get('group', None)
|
||||
values = None
|
||||
if group_uuid:
|
||||
if group:
|
||||
values = request_spec['instance_properties']['system_metadata']
|
||||
values.update({'instance_group': group_uuid})
|
||||
values.update({'group': group})
|
||||
values = {'system_metadata': values}
|
||||
|
||||
updated_instance = driver.instance_update_db(context,
|
||||
@@ -300,19 +300,17 @@ class FilterScheduler(driver.Scheduler):
|
||||
instance_properties = request_spec['instance_properties']
|
||||
instance_type = request_spec.get("instance_type", None)
|
||||
|
||||
# Get the instance_group
|
||||
# Get the group
|
||||
update_group_hosts = False
|
||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
||||
group_uuid = scheduler_hints.get('instance_group', None)
|
||||
if group_uuid:
|
||||
group_data = self.instance_group_data(elevated, group_uuid)
|
||||
if 'anti-affinity' in group_data['instance_group']['policies']:
|
||||
update_group_hosts = True
|
||||
group_hosts = self.instance_group_hosts(elevated, group_data)
|
||||
if 'group_hosts' not in filter_properties:
|
||||
filter_properties.update({'group_hosts': []})
|
||||
user_hosts = filter_properties['group_hosts']
|
||||
filter_properties['group_hosts'] = user_hosts + group_hosts
|
||||
group = scheduler_hints.get('group', None)
|
||||
if group:
|
||||
group_hosts = self.group_hosts(elevated, group)
|
||||
update_group_hosts = True
|
||||
if 'group_hosts' not in filter_properties:
|
||||
filter_properties.update({'group_hosts': []})
|
||||
configured_hosts = filter_properties['group_hosts']
|
||||
filter_properties['group_hosts'] = configured_hosts + group_hosts
|
||||
|
||||
config_options = self._get_configuration_options()
|
||||
|
||||
|
||||
@@ -532,7 +532,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
def test_basic_schedule_run_instances_anti_affinity(self):
|
||||
filter_properties = {'scheduler_hints':
|
||||
{'instance_group': 'fake_uuid'}}
|
||||
{'group': 'cats'}}
|
||||
# Request spec 1
|
||||
instance_opts1 = {'project_id': 1, 'os_type': 'Linux',
|
||||
'memory_mb': 512, 'root_gb': 512,
|
||||
@@ -562,24 +562,19 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
|
||||
self.mox.StubOutWithMock(driver, 'instance_update_db')
|
||||
self.mox.StubOutWithMock(compute_rpcapi.ComputeAPI, 'run_instance')
|
||||
self.mox.StubOutWithMock(sched, 'instance_group_data')
|
||||
self.mox.StubOutWithMock(sched, 'group_hosts')
|
||||
|
||||
instance1_1 = {'uuid': 'fake-uuid1-1'}
|
||||
instance1_2 = {'uuid': 'fake-uuid1-2'}
|
||||
|
||||
group_data = {'instance_group': {'uuid': 'fake_uuid',
|
||||
'policies': ['anti-affinity']},
|
||||
'instances': []}
|
||||
sched.instance_group_data(mox.IgnoreArg(),
|
||||
'fake_uuid').AndReturn(group_data)
|
||||
sched.group_hosts(mox.IgnoreArg(), 'cats').AndReturn([])
|
||||
|
||||
def inc_launch_index1(*args, **kwargs):
|
||||
request_spec1['instance_properties']['launch_index'] = (
|
||||
request_spec1['instance_properties']['launch_index'] + 1)
|
||||
|
||||
expected_metadata = {'system_metadata':
|
||||
{'system': 'metadata',
|
||||
'instance_group': 'fake_uuid'}}
|
||||
{'system': 'metadata', 'group': 'cats'}}
|
||||
driver.instance_update_db(fake_context, instance1_1['uuid'],
|
||||
extra_values=expected_metadata).WithSideEffects(
|
||||
inc_launch_index1).AndReturn(instance1_1)
|
||||
|
||||
Reference in New Issue
Block a user