summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Santa Barbara <justin@fathomdb.com>2011-03-28 17:15:59 +0000
committerTarmac <>2011-03-28 17:15:59 +0000
commitc3c86f994413792cf582df86cf5e16f788005bed (patch)
tree5cbfb1cdb93fd4093e229eb1588b90faaa48ec97
parentc60e53132899b1661d121c6502b050080deae4ce (diff)
parent5a80f8b3d5ae3be774b0b3e1dbc89c9830273eaa (diff)
downloadnova-c3c86f994413792cf582df86cf5e16f788005bed.tar.gz
nova-c3c86f994413792cf582df86cf5e16f788005bed.tar.xz
nova-c3c86f994413792cf582df86cf5e16f788005bed.zip
Assume that if we don't find a VM for an instance in the DB, and the DB state is NOSTATE, that the db instance is in the process of being spawned, and don't mark it SHUTOFF.
Fix for bug#744056
-rw-r--r--nova/compute/manager.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index f43397e36..e0a5e2b3f 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1054,16 +1054,33 @@ class ComputeManager(manager.SchedulerDependentManager):
for db_instance in db_instances:
name = db_instance['name']
+ db_state = db_instance['state']
vm_instance = vm_instances.get(name)
+
if vm_instance is None:
- LOG.info(_("Found instance '%(name)s' in DB but no VM. "
- "Setting state to shutoff.") % locals())
- vm_state = power_state.SHUTOFF
+ # NOTE(justinsb): We have to be very careful here, because a
+ # concurrent operation could be in progress (e.g. a spawn)
+ if db_state == power_state.NOSTATE:
+ # Assume that NOSTATE => spawning
+ # TODO(justinsb): This does mean that if we crash during a
+ # spawn, the machine will never leave the spawning state,
+ # but this is just the way nova is; this function isn't
+ # trying to correct that problem.
+ # We could have a separate task to correct this error.
+ # TODO(justinsb): What happens during a live migration?
+ LOG.info(_("Found instance '%(name)s' in DB but no VM. "
+ "State=%(db_state)s, so assuming spawn is in "
+ "progress.") % locals())
+ vm_state = db_state
+ else:
+ LOG.info(_("Found instance '%(name)s' in DB but no VM. "
+ "State=%(db_state)s, so setting state to "
+ "shutoff.") % locals())
+ vm_state = power_state.SHUTOFF
else:
vm_state = vm_instance.state
vms_not_found_in_db.remove(name)
- db_state = db_instance['state']
if vm_state != db_state:
LOG.info(_("DB/VM state mismatch. Changing state from "
"'%(db_state)s' to '%(vm_state)s'") % locals())