summaryrefslogtreecommitdiffstats
path: root/nova/scheduler/manager.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-19 13:06:02 +0000
committerGerrit Code Review <review@openstack.org>2012-09-19 13:06:02 +0000
commit737ca6e7ecdfa9ffd6744e1e1a54c53c4c897d83 (patch)
treedb1d7a2b462c385d222174681d0f9f4b9019b7c7 /nova/scheduler/manager.py
parentf1189f4774e469e39097e4d10159425a9ed40757 (diff)
parent0cba85cb267994018c8a0d5e40b2ed0b5a7837df (diff)
downloadnova-737ca6e7ecdfa9ffd6744e1e1a54c53c4c897d83.tar.gz
nova-737ca6e7ecdfa9ffd6744e1e1a54c53c4c897d83.tar.xz
nova-737ca6e7ecdfa9ffd6744e1e1a54c53c4c897d83.zip
Merge "Improve error handling of scheduler"
Diffstat (limited to 'nova/scheduler/manager.py')
-rw-r--r--nova/scheduler/manager.py69
1 files changed, 38 insertions, 31 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 5ba375978..450111828 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -22,7 +22,9 @@ Scheduler Service
"""
import functools
+import sys
+from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import db
from nova import exception
@@ -105,12 +107,14 @@ class SchedulerManager(manager.Manager):
except exception.NoValidHost as ex:
# don't re-raise
self._set_vm_state_and_notify('run_instance',
- {'vm_state': vm_states.ERROR},
+ {'vm_state': vm_states.ERROR,
+ 'task_state': None},
context, ex, request_spec)
except Exception as ex:
with excutils.save_and_reraise_exception():
self._set_vm_state_and_notify('run_instance',
- {'vm_state': vm_states.ERROR},
+ {'vm_state': vm_states.ERROR,
+ 'task_state': None},
context, ex, request_spec)
def prep_resize(self, context, image, request_spec, filter_properties,
@@ -140,7 +144,8 @@ class SchedulerManager(manager.Manager):
except Exception as ex:
with excutils.save_and_reraise_exception():
self._set_vm_state_and_notify('prep_resize',
- {'vm_state': vm_states.ERROR},
+ {'vm_state': vm_states.ERROR,
+ 'task_state': None},
context, ex, request_spec)
if reservations:
QUOTAS.rollback(context, reservations)
@@ -163,34 +168,36 @@ class SchedulerManager(manager.Manager):
vm_state = updates['vm_state']
properties = request_spec.get('instance_properties', {})
- # FIXME(comstud): We really need to move error handling closer
- # to where the errors occur so we can deal with errors on
- # individual instances when scheduling multiple.
- if 'instance_uuids' in request_spec:
- instance_uuid = request_spec['instance_uuids'][0]
- else:
- instance_uuid = properties.get('uuid', {})
-
- if instance_uuid:
- state = vm_state.upper()
- LOG.warning(_('Setting instance to %(state)s state.'), locals(),
- instance_uuid=instance_uuid)
-
- # update instance state and notify on the transition
- (old_ref, new_ref) = db.instance_update_and_get_original(context,
- instance_uuid, updates)
- notifications.send_update(context, old_ref, new_ref,
- service="scheduler")
-
- payload = dict(request_spec=request_spec,
- instance_properties=properties,
- instance_id=instance_uuid,
- state=vm_state,
- method=method,
- reason=ex)
-
- notifier.notify(context, notifier.publisher_id("scheduler"),
- 'scheduler.' + method, notifier.ERROR, payload)
+ # NOTE(vish): We shouldn't get here unless we have a catastrophic
+ # failure, so just set all instances to error. if uuid
+ # is not set, instance_uuids will be set to [None], this
+ # is solely to preserve existing behavior and can
+ # be removed along with the 'if instance_uuid:' if we can
+ # verify that uuid is always set.
+ uuids = [properties.get('uuid')]
+ for instance_uuid in request_spec.get('instance_uuids') or uuids:
+ if instance_uuid:
+ compute_utils.add_instance_fault_from_exc(context,
+ instance_uuid, ex, sys.exc_info())
+ state = vm_state.upper()
+ LOG.warning(_('Setting instance to %(state)s state.'),
+ locals(), instance_uuid=instance_uuid)
+
+ # update instance state and notify on the transition
+ (old_ref, new_ref) = db.instance_update_and_get_original(
+ context, instance_uuid, updates)
+ notifications.send_update(context, old_ref, new_ref,
+ service="scheduler")
+
+ payload = dict(request_spec=request_spec,
+ instance_properties=properties,
+ instance_id=instance_uuid,
+ state=vm_state,
+ method=method,
+ reason=ex)
+
+ notifier.notify(context, notifier.publisher_id("scheduler"),
+ 'scheduler.' + method, notifier.ERROR, payload)
# NOTE (masumotok) : This method should be moved to nova.api.ec2.admin.
# Based on bexar design summit discussion,