From 8d1b4cee5b45c90cf1f3651b4a25078ae3f275a2 Mon Sep 17 00:00:00 2001 From: Andrew Clay Shafer Date: Thu, 1 Mar 2012 22:41:15 -0500 Subject: [PATCH] Reset instance to ACTIVE when no hosts found bug 928521 modified nova/scheduler/manager.py to reset vm_state to ACTIVE and set task_state to None when prep_resize raises a NoHostsFound refactored run_instance and prep_resize so they don't go through _schedule and now must be implemented in driver Changed behavior to set vm_state to error on any other exception in prep_resize. Change behavior to change instance vm_state to ERROR on exceptions Added tests that the vm_state gets updated Added tests that schedule_prep_resize and schedule_run_instance have no implementation in the Driver base class Had to adjust methods and tests for Multi scheduler to reflect the new Scheduler contract Change-Id: Ibcac7ef0df3456793a2132beb7a711849510da80 --- nova/scheduler/multi.py | 12 ++++++++---- nova/tests/scheduler/test_multi_scheduler.py | 11 +++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/nova/scheduler/multi.py b/nova/scheduler/multi.py index 3bec060a..d29370ff 100644 --- a/nova/scheduler/multi.py +++ b/nova/scheduler/multi.py @@ -41,10 +41,8 @@ FLAGS = flags.FLAGS FLAGS.register_opts(multi_scheduler_opts) # A mapping of methods to topics so we can figure out which driver to use. -_METHOD_MAP = {'run_instance': 'compute', - 'prep_resize': 'compute', - 'live_migration': 'compute', - 'create_volume': 'volume', +# There are currently no compute methods proxied through the map +_METHOD_MAP = {'create_volume': 'volume', 'create_volumes': 'volume'} @@ -75,3 +73,9 @@ class MultiScheduler(driver.Scheduler): def schedule(self, context, topic, method, *_args, **_kwargs): return self.drivers[topic].schedule(context, topic, method, *_args, **_kwargs) + + def schedule_run_instance(self, *args, **kwargs): + return self.drivers['compute'].schedule_run_instance(*args, **kwargs) + + def schedule_prep_resize(self, *args, **kwargs): + return self.drivers['compute'].schedule_prep_resize(*args, **kwargs) diff --git a/nova/tests/scheduler/test_multi_scheduler.py b/nova/tests/scheduler/test_multi_scheduler.py index 7468a244..3d7220c2 100644 --- a/nova/tests/scheduler/test_multi_scheduler.py +++ b/nova/tests/scheduler/test_multi_scheduler.py @@ -28,13 +28,7 @@ from nova.tests.scheduler import test_scheduler class FakeComputeScheduler(driver.Scheduler): is_fake_compute = True - def schedule_run_instance(self, *args, **kwargs): - pass - - def schedule_live_migration(self, *args, **kwargs): - pass - - def schedule_prep_resize(self, *args, **kwargs): + def schedule_theoretical(self, *args, **kwargs): pass def schedule(self, *args, **kwargs): @@ -79,7 +73,8 @@ class MultiDriverTestCase(test_scheduler.SchedulerTestCase): compute_driver = mgr.drivers['compute'] volume_driver = mgr.drivers['volume'] - test_methods = {compute_driver: ['run_instance', 'prep_resize'], + #no compute methods are proxied at this time + test_methods = {compute_driver: [], volume_driver: ['create_volume', 'create_volumes']} for driver, methods in test_methods.iteritems():