diff options
author | Pádraig Brady <pbrady@redhat.com> | 2012-02-14 16:47:00 +0000 |
---|---|---|
committer | Pádraig Brady <pbrady@redhat.com> | 2012-02-14 22:09:12 +0000 |
commit | 46f7adadaf1d75f36a4544cb9c011056fd6d0e3a (patch) | |
tree | e8c59a443fa0a56b9a000296bab160b0602943d1 /nova/virt/images.py | |
parent | 028c62f378d06ffbae8f698611e1d1ce80f1ede2 (diff) | |
download | nova-46f7adadaf1d75f36a4544cb9c011056fd6d0e3a.tar.gz |
improve stale libvirt images handling fix. Bug 801412
If the unlink fails (because the path wasn't
even created for example), then that will shroud
the original failure. Instead log failure to
remove the stale image, and raise the original exception.
Change-Id: I36c6968823bcf81d704319739b3a992dae75266a
Diffstat (limited to 'nova/virt/images.py')
-rw-r--r-- | nova/virt/images.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py index 9a5a9e1b2c..463c5417e3 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -21,6 +21,7 @@ Handling of VM disk images. """ +import errno import os from nova import exception @@ -45,8 +46,13 @@ def fetch(context, image_href, path, _user_id, _project_id): with open(path, "wb") as image_file: metadata = image_service.get(context, image_id, image_file) except Exception: - os.unlink(path) - raise + with utils.save_and_reraise_exception(): + try: + os.unlink(path) + except OSError, e: + if e.errno != errno.ENOENT: + LOG.warn("unable to remove stale image '%s': %s" % + (path, e.strerror)) return metadata |