Change conductor live migrate task to use select_destinations()
Live migration currently makes calls to scheduler select_hosts() to select a suitable target host if none is given. Other tasks instead queries the scheduler by making calls to select_destinations(). Since the latter call basically returns the same result, and because live migration is the only task using select_hosts(), changing to select_destionations() means the scheduler would no longer need the select_hosts() call. Change-Id: I984ccc2317184ba8f6b292c91717f52a81cf73d7
This commit is contained in:
committed by
Gerrit Code Review
parent
79423472c9
commit
40ecf4ff2a
@@ -160,8 +160,8 @@ class LiveMigrationTask(object):
|
||||
while host is None:
|
||||
self._check_not_over_max_retries(attempted_hosts)
|
||||
filter_properties = {'ignore_hosts': attempted_hosts}
|
||||
host = self.scheduler_rpcapi.select_hosts(self.context,
|
||||
request_spec, filter_properties)[0]
|
||||
host = self.scheduler_rpcapi.select_destinations(self.context,
|
||||
request_spec, filter_properties)[0]['host']
|
||||
try:
|
||||
self._check_compatible_with_source_hypervisor(host)
|
||||
self._call_livem_checks_on_host(host)
|
||||
|
||||
@@ -233,7 +233,8 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
def test_find_destination_works(self):
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.task,
|
||||
'_check_compatible_with_source_hypervisor')
|
||||
self.mox.StubOutWithMock(self.task, '_call_livem_checks_on_host')
|
||||
@@ -243,8 +244,9 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.instance).AndReturn("image")
|
||||
scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host1"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host1'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host1")
|
||||
self.task._call_livem_checks_on_host("host1")
|
||||
|
||||
@@ -255,15 +257,17 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.instance['image_ref'] = ''
|
||||
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.task,
|
||||
'_check_compatible_with_source_hypervisor')
|
||||
self.mox.StubOutWithMock(self.task, '_call_livem_checks_on_host')
|
||||
|
||||
scheduler_utils.build_request_spec(self.context, None,
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host1"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host1'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host1")
|
||||
self.task._call_livem_checks_on_host("host1")
|
||||
|
||||
@@ -273,7 +277,8 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
def _test_find_destination_retry_hypervisor_raises(self, error):
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.task,
|
||||
'_check_compatible_with_source_hypervisor')
|
||||
self.mox.StubOutWithMock(self.task, '_call_livem_checks_on_host')
|
||||
@@ -283,13 +288,15 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.instance).AndReturn("image")
|
||||
scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host1"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host1'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host1")\
|
||||
.AndRaise(error)
|
||||
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host2"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host2'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host2")
|
||||
self.task._call_livem_checks_on_host("host2")
|
||||
|
||||
@@ -308,7 +315,8 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.flags(migrate_max_retries=1)
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.task,
|
||||
'_check_compatible_with_source_hypervisor')
|
||||
self.mox.StubOutWithMock(self.task, '_call_livem_checks_on_host')
|
||||
@@ -318,14 +326,16 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.instance).AndReturn("image")
|
||||
scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host1"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host1'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host1")
|
||||
self.task._call_livem_checks_on_host("host1")\
|
||||
.AndRaise(exception.Invalid)
|
||||
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host2"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host2'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host2")
|
||||
self.task._call_livem_checks_on_host("host2")
|
||||
|
||||
@@ -336,7 +346,8 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.flags(migrate_max_retries=0)
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.task,
|
||||
'_check_compatible_with_source_hypervisor')
|
||||
|
||||
@@ -345,8 +356,9 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
self.instance).AndReturn("image")
|
||||
scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(["host1"])
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
|
||||
[{'host': 'host1'}])
|
||||
self.task._check_compatible_with_source_hypervisor("host1")\
|
||||
.AndRaise(exception.DestinationHypervisorTooOld)
|
||||
|
||||
@@ -356,15 +368,16 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
||||
def test_find_destination_when_runs_out_of_hosts(self):
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi, 'select_hosts')
|
||||
|
||||
self.mox.StubOutWithMock(self.task.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
compute_utils.get_image_metadata(self.context,
|
||||
self.task.image_service, self.instance_image,
|
||||
self.instance).AndReturn("image")
|
||||
scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn({})
|
||||
self.task.scheduler_rpcapi.select_hosts(self.context, mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndRaise(exception.NoValidHost(reason=""))
|
||||
self.task.scheduler_rpcapi.select_destinations(self.context,
|
||||
mox.IgnoreArg(), mox.IgnoreArg()).AndRaise(
|
||||
exception.NoValidHost(reason=""))
|
||||
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(exception.NoValidHost, self.task._find_destination)
|
||||
|
||||
Reference in New Issue
Block a user