summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-01-07 15:17:42 +1300
committerRobert Collins <robertc@robertcollins.net>2013-01-09 14:24:24 +1300
commit37293192c6ae7b841ded4fbccd4d5b36cc89fbaa (patch)
tree1ecf1f2b8ba6b3ae997d35f98b1032b6fad2fc67
parentfa4696ff03260351e0755191e479fcc8026ab828 (diff)
Cope better with out of sync bm data.
The baremetal hypervisor tracks references to instances which are deleted asynchronously from the commit to the nova bm. As such, its a normal but rare condition for a bare metal node to refer to a deleted (and even garbage collected) nova instance. We should treat such instances are deleted rather than erroring on any call through list_instances(), permitting starting new instances and listing instances to work - fixing bug: 1096722. Pathologically, the database may suffer permanent skew, which means we need a way to fix it (and thats tracked as a separate bug). Change-Id: Ic21ff66b1fc0ad64bb5feff26291873b96d20e4e
-rw-r--r--nova/virt/baremetal/driver.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py
index e517b399d..a27056994 100644
--- a/nova/virt/baremetal/driver.py
+++ b/nova/virt/baremetal/driver.py
@@ -169,11 +169,19 @@ class BareMetalDriver(driver.ComputeDriver):
l = []
ctx = nova_context.get_admin_context()
for node in _get_baremetal_nodes(ctx):
- if node['instance_uuid']:
- inst = self.virtapi.instance_get_by_uuid(ctx,
- node['instance_uuid'])
- if inst:
- l.append(inst['name'])
+ if not node['instance_uuid']:
+ # Not currently assigned to an instance.
+ continue
+ try:
+ inst = self.virtapi.instance_get_by_uuid(
+ ctx, node['instance_uuid'])
+ except exception.InstanceNotFound:
+ # Assigned to an instance that no longer exists.
+ LOG.warning(_("Node %(id)r assigned to instance %(uuid)r "
+ "which cannot be found."),
+ dict(id=node['id'], uuid=node['instance_uuid']))
+ continue
+ l.append(inst['name'])
return l
def spawn(self, context, instance, image_meta, injected_files,