25505808 stale .downloading files in image cache block instance deployment
authorSean Wilcox <sean.wilcox@oracle.com>
Tue, 07 Feb 2017 15:11:24 -0700
changeset 7652 8ea2de474b66
parent 7651 70c0daa6928d
child 7655 b5ff34d7b33b
25505808 stale .downloading files in image cache block instance deployment
components/openstack/nova/files/solariszones/driver.py
--- a/components/openstack/nova/files/solariszones/driver.py	Fri Feb 03 12:49:15 2017 -0800
+++ b/components/openstack/nova/files/solariszones/driver.py	Tue Feb 07 15:11:24 2017 -0700
@@ -1151,7 +1151,6 @@
         with lockutils.lock('glance-image-%s' % iref):
             if os.path.isfile(downloading):
                 LOG.debug(_('Cleaning partial download of %s' % iref))
-                os.unlink(image)
                 os.unlink(downloading)
 
             elif os.path.exists(image):
@@ -1161,12 +1160,9 @@
 
             LOG.debug(_("Fetching new Glance image: id %s") % iref)
             try:
-                # touch the empty .downloading file
-                with open(downloading, 'w'):
-                    pass
-                images.fetch(context, iref, image, instance['user_id'],
+                images.fetch(context, iref, downloading, instance['user_id'],
                              instance['project_id'])
-                os.unlink(downloading)
+                os.rename(downloading, image)
                 return image
             except Exception as reason:
                 LOG.exception(_("Unable to fetch Glance image: id %s: %s")