From f8f69dc2edd0da19e2726a5e2068dd22e7ced0a2 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Tue, 27 Mar 2012 14:30:37 +1100 Subject: A missing checksum does not mean the image is corrupt. This is a logic error in the code. A missing checksum should not imply that the image is corrupt. Note that corrupt images are only logged, not removed, so there is no data loss for users with this bug. Change-Id: Ic644517d3b8e9646fe943e5cef485c4168ebb5b5 --- nova/tests/test_imagecache.py | 3 +++ nova/virt/libvirt/imagecache.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index c748abbae..09f5f9fce 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -660,6 +660,9 @@ class ImageCacheManagerTestCase(test.TestCase): fq_path('%s_10737418240' % hashed_1)]: self.assertTrue(rem in image_cache_manager.removable_base_files) + # Ensure there are no "corrupt" images as well + self.assertTrue(len(image_cache_manager.corrupt_base_files), 0) + def test_verify_base_images_no_base(self): self.flags(instances_path='/tmp/no/such/dir/name/please') image_cache_manager = imagecache.ImageCacheManager() diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py index 25455a07c..07bab5cd3 100644 --- a/nova/virt/libvirt/imagecache.py +++ b/nova/virt/libvirt/imagecache.py @@ -303,8 +303,11 @@ class ImageCacheManager(object): if (base_file and os.path.exists(base_file) and os.path.isfile(base_file)): - # _verify_checksum returns True if the checksum is ok. - image_bad = not self._verify_checksum(img_id, base_file) + # _verify_checksum returns True if the checksum is ok, and None if + # there is no checksum file + checksum_result = self._verify_checksum(img_id, base_file) + if not checksum_result is None: + image_bad = not checksum_result instances = [] if img_id in self.used_images: -- cgit