summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorTim Pownall <tim.pownall@rackspace.com>2016-03-02 14:38:24 -0600
committerTim Pownall <pownalltim@gmail.com>2016-03-09 09:32:05 -0600
commit32d576427179965def0a1757dc86a492e1c3756d (patch)
treeb03e7b4c92284cf8fd209341b0829378b08904bf /plugins
parentabc0f8fce23c933bb85176c6bd5b2afa20788e38 (diff)
downloadnova-32d576427179965def0a1757dc86a492e1c3756d.tar.gz
xenapi: fix when tar exits early during download
When downloading a streamed chunk from swift through glance gives tar invalid input, tar will exit, but leave the plugin still trying to write data to the dead process. To stop this we can spot when the tar process exits early, and be sure to stop trying to write more data to the dead process. Change-Id: Ic2bc89fa6d08db505b044a9498c1bfa5b884a056 Closes-Bug: 1552293
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
index 60d680ca93..73ffa14cbe 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
@@ -460,7 +460,26 @@ def extract_tarball(fileobj, path, callback=None):
callback(chunk)
tar_proc.stdin.write(chunk)
+
+ # NOTE(tpownall): If we do not poll for the tar process exit
+ # code when tar has exited pre maturely there is the chance
+ # that tar will become a defunct zombie child under glance plugin
+ # and re parented under init forever waiting on the stdin pipe to
+ # close. Polling for the exit code allows us to break the pipe.
+ returncode = tar_proc.poll()
+ tar_pid = tar_proc.pid
+ if returncode is not None:
+ LOG.error("tar extract with process id '%(pid)s' "
+ "exited early with '%(rc)s'" %
+ {'pid': tar_pid, 'rc': returncode})
+ raise SubprocessException(
+ ' '.join(tar_cmd), returncode, "", "")
+
+ except SubprocessException:
+ # no need to kill already dead process
+ raise
except Exception:
+ LOG.exception("Failed while sending data to tar pid: %s" % tar_pid)
try_kill_process(tar_proc)
raise