Image uploads should always happen in the background

Sufficiently large image uploads into Glance from Horizon can cause
timeout errors, since the image upload needs to complete before the
view can render, and such activities can cause browser timeouts.
Since the webserver already has the file, and close-to-open semantics
should prevent cleanups from losing any data, just send it in a
background thread, the same way as if you told Horizon to fetch it
from a remote location.

Change-Id: Ia056367032e0d08edf6f36a8e9f900fddba85fdf
Closes-Bug: 1322399
This commit is contained in:
Nicolas Simonds 2014-05-22 18:27:42 -07:00
parent af0e253d8d
commit 99aa842e97

View File

@ -90,14 +90,17 @@ def image_update(request, image_id, **kwargs):
def image_create(request, **kwargs):
copy_from = None
if kwargs.get('copy_from'):
copy_from = kwargs.pop('copy_from')
copy_from = kwargs.pop('copy_from', None)
data = kwargs.pop('data', None)
image = glanceclient(request).images.create(**kwargs)
if copy_from:
if data:
thread.start_new_thread(image_update,
(request, image.id),
{'data': data,
'purge_props': False})
elif copy_from:
thread.start_new_thread(image_update,
(request, image.id),
{'copy_from': copy_from,