From 979d1116fe1fcae3e67974dd618854d6f66a6f5d Mon Sep 17 00:00:00 2001 From: John Garbutt Date: Tue, 18 Nov 2014 14:31:34 +0000 Subject: [PATCH] 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: e039b036b5e9dbaff8b37f7ab22c209b71bdc182 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 --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 66e361b5ce24..1da5be5b0828 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -212,12 +212,11 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port, compression_level = properties.get('xenapi_image_compression_level') - try: - utils.create_tarball( - None, staging_path, callback=send_chunked_transfer_encoded, - compression_level=compression_level) - finally: - send_chunked_transfer_encoded('') # Chunked-Transfer terminator + utils.create_tarball( + None, staging_path, callback=send_chunked_transfer_encoded, + compression_level=compression_level) + + send_chunked_transfer_encoded('') # Chunked-Transfer terminator bytes_written = callback_data['bytes_written'] logging.info("Wrote %d bytes to %s" % (bytes_written, url))