Run zuul v3 launcher

This makes zuul-launcher run the actual zuul v3 launcher rather
than the zuul v2.5 ansible launcher.  It also cleans up the
shutdown process a bit.

Change-Id: Iedb1c23c3cb46090859c520e10043f0b7083a862
This commit is contained in:
James E. Blair 2017-02-13 16:17:22 -08:00
parent 5d944abb65
commit 29b9c96a43
2 changed files with 16 additions and 6 deletions

View File

@ -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)

View File

@ -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")