]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Keep reading stdout/stderr until after kill
authorJohn Schwarz <jschwarz@redhat.com>
Wed, 14 Oct 2015 12:39:33 +0000 (15:39 +0300)
committerJohn Schwarz <jschwarz@redhat.com>
Thu, 19 Nov 2015 17:14:13 +0000 (19:14 +0200)
commitddaee9f060c8fd1585d3e06e04eb301518ff90e0
treed3719e3a4b7cf063bc6b411b2293ea29c1f32706
parent44cc4b9a632523d997cc3f03dfed91d3c92259c5
Keep reading stdout/stderr until after kill

Currently, when calling AsyncProcess.stop(), the code stops the stdout
and stderr readers and kills the process. There exists an end case (as
described in the bug report) in which after the readers have been
stopped the sub-process will generate a substantial amount of outputs to
either fd. Since the 'subprocess' module is launched with
subprocess.PIPE as stdout/stderr, and since Linux's pipes can be filled
to the point where writing new data to them will block, this may cause a
deadlock if the sub-process has a signal handler for the signal (for
example, the process is handling SIGTERM to produce a graceful exit of
the program).

Therefore, this patch proposes to only kill the readers until AFTER
wait() returned and the process truly died. Also, relying on _kill_event
had to cease since invoking its send() method caused a logical loop back
to _kill, causing eventlet errors.

A different possible solution is closing the stdout/stderr pipes. Alas,
this may raise an exception in the sub-process ("what? No stdout?!
Crash!") and defeats the 'graceful' part of the process.

Closes-Bug: #1506021
Change-Id: I506c41c634a8d656d81a8ad7963412b834bdfa5b
neutron/agent/linux/async_process.py
neutron/tests/unit/agent/linux/failing_process.py [new file with mode: 0644]
neutron/tests/unit/agent/linux/test_async_process.py