summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <pbrady@redhat.com>2012-02-02 14:56:54 +0000
committerPádraig Brady <pbrady@redhat.com>2012-02-02 15:12:58 +0000
commit3db5b1e7099e1c10d557577350dc28e323c70af4 (patch)
treeded3e3a2430b23ddc7e7b05a135bf9ab86523f52
parent638ea669694f3083145e2300b362ded6749d74a1 (diff)
downloadnova-3db5b1e7099e1c10d557577350dc28e323c70af4.tar.gz
nova-3db5b1e7099e1c10d557577350dc28e323c70af4.tar.xz
nova-3db5b1e7099e1c10d557577350dc28e323c70af4.zip
fix stale libvirt images on download failure. Bug 801412
If we've just truncated/created the file to receive the download, but the download fails, then delete the file. Otherwise subsequent downloads would not be attempted. Change-Id: Ibe9ba199b2f424d570ce7aedfb768ce283816a3b
-rw-r--r--nova/virt/images.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py
index b884e5124..25f968185 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -41,8 +41,12 @@ def fetch(context, image_href, path, _user_id, _project_id):
# checked before we got here.
(image_service, image_id) = nova.image.get_image_service(context,
image_href)
- with open(path, "wb") as image_file:
- metadata = image_service.get(context, image_id, image_file)
+ try:
+ with open(path, "wb") as image_file:
+ metadata = image_service.get(context, image_id, image_file)
+ except Exception:
+ os.unlink(path)
+ raise
return metadata