xenapi: send chunk terminator on subprocess exc
During chunk upload if a subprocess exception is thrown, a malformed chunk upload occurs. This patch adds logging for subprocess exceptions and sends the terminator even in the event of a subprocess exception. The incomplete file upload will then be cleaned up by the client. Change-Id: I559f201430bcd4c36d669c7772a10bfe3cd54d41 Closes-Bug: 1365637
This commit is contained in:
parent
deacd9d1cc
commit
e039b036b5
@ -200,14 +200,12 @@ 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')
|
||||||
|
|
||||||
utils.create_tarball(
|
|
||||||
None, staging_path, callback=send_chunked_transfer_encoded,
|
|
||||||
compression_level=compression_level)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn.send("0\r\n\r\n") # Chunked-Transfer terminator
|
utils.create_tarball(
|
||||||
except Exception, error:
|
None, staging_path, callback=send_chunked_transfer_encoded,
|
||||||
raise RetryableError(error)
|
compression_level=compression_level)
|
||||||
|
finally:
|
||||||
|
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))
|
||||||
|
@ -101,6 +101,10 @@ def finish_subprocess(proc, cmdline, cmd_input=None, ok_exit_codes=None):
|
|||||||
|
|
||||||
ret = proc.returncode
|
ret = proc.returncode
|
||||||
if ret not in ok_exit_codes:
|
if ret not in ok_exit_codes:
|
||||||
|
LOG.error("Command '%(cmdline)s' with process id '%(pid)s' expected "
|
||||||
|
"return code in '%(ok)s' but got '%(rc)s': %(err)s" %
|
||||||
|
{'cmdline': cmdline, 'pid': proc.pid, 'ok': ok_exit_codes,
|
||||||
|
'rc': ret, 'err': err})
|
||||||
raise SubprocessException(' '.join(cmdline), ret, out, err)
|
raise SubprocessException(' '.join(cmdline), ret, out, err)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user