xenapi: don't send terminating chunk on errors

If we send the terminator on an error, it looks like we have actually
completed the upload, when that was not actually the case, we have
failed, and ideally we want glance to notice and mark the snapshot as
failed.

This partly reverts the following commit:
e039b036b5

It is not a full revert of the above commit, and some of the refactoring
and error handling changes are still useful.

Closes-Bug: #1398826
Change-Id: Ib608a32556135a5b7e666d02c4ee77722ea6e07c
This commit is contained in:
John Garbutt 2014-11-18 14:31:34 +00:00 committed by John Garbutt
parent f078f20dac
commit 979d1116fe

View File

@ -212,12 +212,11 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
compression_level = properties.get('xenapi_image_compression_level') compression_level = properties.get('xenapi_image_compression_level')
try: utils.create_tarball(
utils.create_tarball( None, staging_path, callback=send_chunked_transfer_encoded,
None, staging_path, callback=send_chunked_transfer_encoded, compression_level=compression_level)
compression_level=compression_level)
finally: send_chunked_transfer_encoded('') # Chunked-Transfer terminator
send_chunked_transfer_encoded('') # Chunked-Transfer terminator
bytes_written = callback_data['bytes_written'] bytes_written = callback_data['bytes_written']
logging.info("Wrote %d bytes to %s" % (bytes_written, url)) logging.info("Wrote %d bytes to %s" % (bytes_written, url))