summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <pbrady@redhat.com>2012-03-16 16:00:43 +0000
committerPádraig Brady <pbrady@redhat.com>2012-03-16 18:41:37 +0000
commit1d94d55775b78a5d37658bb641c225bc49510620 (patch)
tree5ebb9fd2e9485206d452bc869ab67782e19b1982
parent1ecf2c5b77d21015bbb4cc9edf7abf96355bb8e3 (diff)
allow the compute service to start with missing libvirt disks
* nova/virt/libvirt/connection.py: Program defensively and handle the case of missing instance disks and log the error rather than propagating that exception up (which triggers nova.service to fail). * Fixes bug 957110 Change-Id: I1a414f56661843ff6b886e6ebf6f614fcb5a5f31
-rw-r--r--nova/virt/libvirt/connection.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 2f35c664c..72340d474 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -39,6 +39,7 @@ Supports KVM, LXC, QEMU, UML, and XEN.
"""
+import errno
import hashlib
import functools
import glob
@@ -2110,6 +2111,10 @@ class LibvirtConnection(driver.ComputeDriver):
locals())
continue
+ # get the real disk size or
+ # raise a localized error if image is unavailable
+ dk_size = int(os.path.getsize(path))
+
disk_type = driver_nodes[cnt].get('type')
if disk_type == "qcow2":
out, err = utils.execute('qemu-img', 'info', path)
@@ -2119,13 +2124,9 @@ class LibvirtConnection(driver.ComputeDriver):
if i.strip().find('virtual size') >= 0]
virt_size = int(size[0])
- # real disk size:
- dk_size = int(os.path.getsize(path))
-
# backing file:(actual path:)
backing_file = libvirt_utils.get_disk_backing_file(path)
else:
- dk_size = int(os.path.getsize(path))
backing_file = ""
virt_size = 0
@@ -2153,11 +2154,18 @@ class LibvirtConnection(driver.ComputeDriver):
instances_name = self.list_instances()
instances_sz = 0
for i_name in instances_name:
- disk_infos = utils.loads(self.get_instance_disk_info(i_name))
- for info in disk_infos:
- i_vt_sz = int(info['virt_disk_size'])
- i_dk_sz = int(info['disk_size'])
- instances_sz += i_vt_sz - i_dk_sz
+ try:
+ disk_infos = utils.loads(self.get_instance_disk_info(i_name))
+ for info in disk_infos:
+ i_vt_sz = int(info['virt_disk_size'])
+ i_dk_sz = int(info['disk_size'])
+ instances_sz += i_vt_sz - i_dk_sz
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ LOG.error(_("Getting disk size of %(i_name)s: %(e)s") %
+ locals())
+ else:
+ raise
# Disk available least size
available_least_size = dk_sz_gb * (1024 ** 3) - instances_sz