Stop jobs when executor stops
If the executor stops while jobs are running, those jobs are not explicitly aborted. In production, the process exit would cause all of the jobs to terminate and the gearman disconnection would report a failure, however, in tests the python process may continue and the ansible threads would essentially leak into a subsequent test. This is especially likely to happen if a test holds jobs in build, and then fails while those jobs are still held. Those threads will continue to wait to be released while further tests continue to run. Because all tests assert that git.Repo objects are not leaked, the outstanding reference that the leaked threads have to a git.Repo object trips that assertion and all subsequent tests in the same test runner fail. This adds code to the executor shutdown to stop all jobs at the start of the shutdown process. It also adds a test which shuts down the executor while jobs are held and asserts that after shutdown, those threads are stopped, and no git repo objects are leaked. Change-Id: I9d73775a13c289ef922c27b29162efcfca3950a9
This commit is contained in:
@@ -344,10 +344,17 @@ class ExecutorServer(object):
|
||||
def stop(self):
|
||||
self.log.debug("Stopping")
|
||||
self._running = False
|
||||
self.worker.shutdown()
|
||||
self._command_running = False
|
||||
self.command_socket.stop()
|
||||
self.update_queue.put(None)
|
||||
|
||||
for job_worker in self.job_workers.values():
|
||||
try:
|
||||
job_worker.stop()
|
||||
except Exception:
|
||||
self.log.exception("Exception sending stop command "
|
||||
"to worker:")
|
||||
self.worker.shutdown()
|
||||
self.log.debug("Stopped")
|
||||
|
||||
def pause(self):
|
||||
|
||||
Reference in New Issue
Block a user