summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-02-17 20:50:37 +0000
committerGerrit Code Review <review@openstack.org>2012-02-17 20:50:37 +0000
commit4a9791b4c76e2516586caa72effda3c1f8e635ab (patch)
tree921a3e7625d4b4ec90f42e21fcff9974d0667982 /nova
parent18a8eae4bfa6f022ea97155596dfb80ae7401ed6 (diff)
parent46f7adadaf1d75f36a4544cb9c011056fd6d0e3a (diff)
Merge "improve stale libvirt images handling fix. Bug 801412"
Diffstat (limited to 'nova')
-rw-r--r--nova/virt/images.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py
index 1f3228b5e..12510c792 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
@@ -55,8 +56,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