diff --git a/zuul/cmd/launcher.py b/zuul/cmd/launcher.py index 49643aee05..596fd1ac7a 100644 --- a/zuul/cmd/launcher.py +++ b/zuul/cmd/launcher.py @@ -29,7 +29,7 @@ import sys import signal import zuul.cmd -import zuul.launcher.ansiblelaunchserver +import zuul.launcher.server # No zuul imports that pull in paramiko here; it must not be # imported until after the daemonization. @@ -52,7 +52,7 @@ class Launcher(zuul.cmd.ZuulApp): action='store_true', help='keep local jobdirs after run completes') parser.add_argument('command', - choices=zuul.launcher.ansiblelaunchserver.COMMANDS, + choices=zuul.launcher.server.COMMANDS, nargs='?') self.args = parser.parse_args() @@ -79,8 +79,8 @@ class Launcher(zuul.cmd.ZuulApp): self.log = logging.getLogger("zuul.Launcher") - LaunchServer = zuul.launcher.ansiblelaunchserver.LaunchServer - self.launcher = LaunchServer(self.config, + LaunchServer = zuul.launcher.server.LaunchServer + self.launcher = LaunchServer(self.config, self.connections, keep_jobdir=self.args.keep_jobdir) self.launcher.start() @@ -102,7 +102,7 @@ def main(): server.parse_arguments() server.read_config() - if server.args.command in zuul.launcher.ansiblelaunchserver.COMMANDS: + if server.args.command in zuul.launcher.server.COMMANDS: server.send_command(server.args.command) sys.exit(0) diff --git a/zuul/launcher/server.py b/zuul/launcher/server.py index 4e0fdd2eb8..0848b0b8e6 100644 --- a/zuul/launcher/server.py +++ b/zuul/launcher/server.py @@ -28,13 +28,17 @@ import yaml import gear -import zuul.merger +import zuul.merger.merger import zuul.ansible.library from zuul.lib import commandsocket ANSIBLE_WATCHDOG_GRACE = 5 * 60 +COMMANDS = ['stop', 'pause', 'unpause', 'graceful', 'verbose', + 'unverbose'] + + class Watchdog(object): def __init__(self, timeout, function, args): self.timeout = timeout @@ -280,6 +284,7 @@ class LaunchServer(object): self.worker.shutdown() self._command_running = False self.command_socket.stop() + self.update_queue.put(None) self.log.debug("Stopped") def pause(self): @@ -325,6 +330,9 @@ class LaunchServer(object): def _innerUpdateLoop(self): # Inside of a loop that keeps the main repository up to date task = self.update_queue.get() + if task is None: + # We are asked to stop + return self.log.info("Updating repo %s from %s" % (task.project, task.url)) self.merger.updateRepo(task.project, task.url) self.log.debug("Finished updating repo %s from %s" % @@ -360,6 +368,8 @@ class LaunchServer(object): except Exception: self.log.exception("Exception while running job") job.sendWorkException(traceback.format_exc()) + except gear.InterruptedError: + pass except Exception: self.log.exception("Exception while getting job")