diff options
| author | David Subiros <david.perez5@hp.com> | 2011-11-16 17:31:29 +0000 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-12-12 17:27:03 -0800 |
| commit | ff753cd608973f5d72a80aef0f9fb8a646fccc3f (patch) | |
| tree | 0b51b6b1263d29fef254fb1e61863fcc55b56c10 /nova/scheduler | |
| parent | d3b75b75aa937380f04b5320b70c8673821af203 (diff) | |
| download | nova-ff753cd608973f5d72a80aef0f9fb8a646fccc3f.tar.gz nova-ff753cd608973f5d72a80aef0f9fb8a646fccc3f.tar.xz nova-ff753cd608973f5d72a80aef0f9fb8a646fccc3f.zip | |
Vm state management and error states
this implements the blueprint nova-vm-state-management
It implements the following functionalities:
- Filter compute api calls according to state of the VM
(defined in compute/state_checker).
- Sets error state if the scheduler cannot allocate the VM in any host
- Handles the create/delete concurrency in the compute manager
Change-Id: Ie6d016b7d4781f70bb5967f204fa88a6412bd727
Diffstat (limited to 'nova/scheduler')
| -rw-r--r-- | nova/scheduler/manager.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 5aadc6e82..38dda9931 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -25,12 +25,13 @@ import functools from nova.compute import vm_states from nova import db +from nova import exception from nova import flags from nova import log as logging from nova import manager from nova import rpc -from nova import utils from nova.scheduler import zone_manager +from nova import utils LOG = logging.getLogger('nova.scheduler.manager') FLAGS = flags.FLAGS @@ -101,17 +102,24 @@ class SchedulerManager(manager.Manager): # Scheduler methods are responsible for casting. try: return real_meth(*args, **kwargs) - except Exception as e: - # If this affects a particular instance, move that - # instance to the ERROR state - if 'instance_id' in kwargs: - instance_id = kwargs['instance_id'] - LOG.warning(_("Failed to %(driver_method)s: %(e)s. " - "Putting instance %(instance_id)s into " + except exception.NoValidHost as ex: + self._set_instance_error(method, context, ex, *args, **kwargs) + except Exception as ex: + with utils.save_and_reraise_exception(): + self._set_instance_error(method, context, ex, *args, **kwargs) + + # NOTE (David Subiros) : If the exception is raised ruing run_instance + # method, the DB record probably does not exist yet. + def _set_instance_error(self, method, context, ex, *args, **kwargs): + """Sets VM to Error state""" + LOG.warning(_("Failed to schedule_%(method)s: %(ex)s") % locals()) + if method == "start_instance" or method == "run_instance": + instance_id = kwargs['instance_id'] + if instance_id: + LOG.warning(_("Setting instance %(instance_id)s to " "ERROR state.") % locals()) - db.instance_update(context, kwargs['instance_id'], - dict(vm_state=vm_states.ERROR)) - raise + db.instance_update(context, instance_id, + {'vm_state': vm_states.ERROR}) # NOTE (masumotok) : This method should be moved to nova.api.ec2.admin. # Based on bexar design summit discussion, |
