From ccdb02105acf32a4a0c81d688749475d8abedf4b Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 5 Jul 2012 13:49:02 +0100 Subject: Don't catch & ignore exceptions when setting up LXC container filesystems The 'setup_container' method in nova/disk/api.py may well raise an exception if something goes wrong when setting up the LXC container's root filesystem. Currently it just catches & logs any exception. The caller thus always thinks everything worked & goes onto boot the container despite there being no root filesystem available for it. The fix is to simply remove the bogus exception catching completely Change-Id: I2691713f11cced1561f347819875f490b8aaafef Signed-off-by: Daniel P. Berrange --- nova/virt/disk/api.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index 3e66cd2a7..766c9ebd7 100644 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -271,14 +271,15 @@ def setup_container(image, container_dir=None, use_cow=False): LXC does not support qcow2 images yet. """ - try: - img = _DiskImage(image=image, use_cow=use_cow, mount_dir=container_dir) - if img.mount(): - return img - else: - raise exception.NovaException(img.errors) - except Exception, exn: - LOG.exception(_('Failed to mount filesystem: %s'), exn) + img = _DiskImage(image=image, use_cow=use_cow, mount_dir=container_dir) + if img.mount(): + return img + else: + LOG.error(_("Failed to mount container filesystem '%(image)s' " + "on '%(target)s': %(errors)s") % + {"image": img, "target": container_dir, + "errors": img.errors}) + raise exception.NovaException(img.errors) def destroy_container(img): @@ -293,7 +294,7 @@ def destroy_container(img): if img: img.umount() except Exception, exn: - LOG.exception(_('Failed to remove container: %s'), exn) + LOG.exception(_('Failed to unmount container filesystem: %s'), exn) def inject_data_into_fs(fs, key, net, metadata, admin_password, execute): -- cgit