From 47aa6b12b2c9d819a626934e0ab98e7767d44bab Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Mon, 7 Jan 2019 10:19:48 -0500 Subject: [PATCH] Ensure command_socket is last thing to close This updates all services to how zuul-scheduler works, we close the command_socket at the last possible moment. This also means we can now use the command socket on the filesystem as an idicator that zuul properly shutdown. Change-Id: I5fe1bc96c87e1177a2b94d73a9cbe505a7807202 Signed-off-by: Paul Belanger --- zuul/executor/server.py | 2 +- zuul/lib/fingergw.py | 15 ++++++++------- zuul/merger/server.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 79566282ce..854e58df45 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -2313,7 +2313,6 @@ class ExecutorServer(object): self._running = False self._command_running = False workers = list(self.job_workers.values()) - self.command_socket.stop() for job_worker in workers: try: @@ -2344,6 +2343,7 @@ class ExecutorServer(object): self.statsd.gauge(base_key + '.pct_used_ram', 0) self.statsd.gauge(base_key + '.running_builds', 0) + self.command_socket.stop() self.log.debug("Stopped") def join(self): diff --git a/zuul/lib/fingergw.py b/zuul/lib/fingergw.py index 51cfa91dde..4f603f3242 100644 --- a/zuul/lib/fingergw.py +++ b/zuul/lib/fingergw.py @@ -184,13 +184,6 @@ class FingerGateway(object): self.log.info("Finger gateway is started") def stop(self): - if self.command_socket: - self.command_running = False - try: - self.command_socket.stop() - except Exception: - self.log.exception("Error stopping command socket:") - if self.server: try: self.server.shutdown() @@ -206,6 +199,14 @@ class FingerGateway(object): except Exception: self.log.exception("Error stopping RCP client:") + if self.command_socket: + self.command_running = False + + try: + self.command_socket.stop() + except Exception: + self.log.exception("Error stopping command socket:") + self.log.info("Finger gateway is stopped") def wait(self): diff --git a/zuul/merger/server.py b/zuul/merger/server.py index b7d0fd42e3..a2f23034d2 100644 --- a/zuul/merger/server.py +++ b/zuul/merger/server.py @@ -87,8 +87,8 @@ class MergeServer(object): self.log.debug("Stopping") self._running = False self._command_running = False - self.command_socket.stop() self.worker.shutdown() + self.command_socket.stop() self.log.debug("Stopped") def join(self):