ansible-runner icon indicating copy to clipboard operation
ansible-runner copied to clipboard

Insufficient subprocess control and termination (SIGHUP)

Open tympanix opened this issue 2 years ago • 0 comments

It seems like ansible-runner is leaving running subprocesses behind (using ansible-runner as a Python module). Browsing through the code, this is a product of multiple bad design decisions (imo):

  1. The subprocess (pexpect) has ignore_sighup=True thus the subprocesses persists after parent process exits. There is no exposed options to change this behaviour.
  2. The PID of the subprocess nor the underlying subprocess object itself is available to the end user.
  3. The cancel_callback is the only method of terminating the subprocess, but has a default timeout of 5 seconds (too much imho). Options to change default timeout of pexpect is not clearly documented (requires debugging/reading source code)

All in all, end users of this library are inherently expected to terminate ill-behaved subprocesses themselves (or say in case of the parent process exiting rapidly) but is left with limited options.

tympanix avatar Jan 23 '22 15:01 tympanix