Delete image objects after failed upload
In glance with PUT uploads, if the PUT fails, you're left with a non-working image shell. There is no point to that. Change-Id: Id47a10eab76f851202538c8b353288cb859656b8
This commit is contained in:
parent
502a4bba86
commit
d5e0745fc2
@ -2338,15 +2338,28 @@ class OpenStackCloud(object):
|
|||||||
image_kwargs[k] = int(image_kwargs[k])
|
image_kwargs[k] = int(image_kwargs[k])
|
||||||
image = self.manager.submitTask(_tasks.ImageCreate(
|
image = self.manager.submitTask(_tasks.ImageCreate(
|
||||||
name=name, **image_kwargs))
|
name=name, **image_kwargs))
|
||||||
self.manager.submitTask(_tasks.ImageUpload(
|
try:
|
||||||
image_id=image.id, image_data=image_data))
|
self.manager.submitTask(_tasks.ImageUpload(
|
||||||
|
image_id=image.id, image_data=image_data))
|
||||||
|
except Exception:
|
||||||
|
self.log.debug("Deleting failed upload of image {name}".format(
|
||||||
|
image=image['name']))
|
||||||
|
self.manager.submitTask(_tasks.ImageDelete(image_id=image.id))
|
||||||
|
raise
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def _upload_image_put_v1(self, name, image_data, **image_kwargs):
|
def _upload_image_put_v1(self, name, image_data, **image_kwargs):
|
||||||
image = self.manager.submitTask(_tasks.ImageCreate(
|
image = self.manager.submitTask(_tasks.ImageCreate(
|
||||||
name=name, **image_kwargs))
|
name=name, **image_kwargs))
|
||||||
self.manager.submitTask(_tasks.ImageUpdate(
|
try:
|
||||||
image=image, data=image_data))
|
self.manager.submitTask(_tasks.ImageUpdate(
|
||||||
|
image=image, data=image_data))
|
||||||
|
except Exception:
|
||||||
|
self.log.debug("Deleting failed upload of image {name}".format(
|
||||||
|
image=image['name']))
|
||||||
|
self.manager.submitTask(_tasks.ImageDelete(image_id=image.id))
|
||||||
|
raise
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def _upload_image_put(self, name, filename, **image_kwargs):
|
def _upload_image_put(self, name, filename, **image_kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user