From 3e4e339114d9c765716301c0757010f76b561571 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 8 Feb 2018 11:48:13 -0800 Subject: [PATCH] Drop cancel_q from the monitor() function Not needed, builds are canceled by writing a 'CANCEL' file in the results directory. --- src/pylorax/api/queue.py | 18 +++++++++++------- src/sbin/lorax-composer | 6 +----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index db0de2f7..08b4062c 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -35,9 +35,13 @@ from pylorax.installer import novirt_install from pylorax.sysutils import joinpaths # TODO needs a quit queue to cleanly manage quitting -def monitor(cfg, cancel_q): +def monitor(cfg): """ Monitor the queue for new compose requests + :param cfg: Configuration settings + :type cfg: ComposerConfig + :returns: Does not return + The queue has 2 subdirectories, new and run. When a compose is ready to be run a symlink to the uniquely named results directory should be placed in ./queue/new/ @@ -50,9 +54,9 @@ def monitor(cfg, cancel_q): If the system is restarted while a compose is running it will move any old symlinks from ./queue/run/ to ./queue/new/ and rerun them. """ - def queue_sort(job): + def queue_sort(uuid): """Sort the queue entries by their mtime, not their names""" - return os.stat(joinpaths(cfg.composer_dir, "queue/new", job)).st_mtime + return os.stat(joinpaths(cfg.composer_dir, "queue/new", uuid)).st_mtime # Move any symlinks in the run queue back to the new queue for link in os.listdir(joinpaths(cfg.composer_dir, "queue/run")): @@ -62,15 +66,15 @@ def monitor(cfg, cancel_q): log.debug("Moved unfinished compose %s back to new state", src) while True: - jobs = sorted(os.listdir(joinpaths(cfg.composer_dir, "queue/new")), key=queue_sort) + uuids = sorted(os.listdir(joinpaths(cfg.composer_dir, "queue/new")), key=queue_sort) # Pick the oldest and move it into ./run/ - if not jobs: + if not uuids: # No composes left to process, sleep for a bit time.sleep(30) else: - src = joinpaths(cfg.composer_dir, "queue/new", jobs[0]) - dst = joinpaths(cfg.composer_dir, "queue/run", jobs[0]) + src = joinpaths(cfg.composer_dir, "queue/new", uuids[0]) + dst = joinpaths(cfg.composer_dir, "queue/run", uuids[0]) try: os.rename(src, dst) except OSError: diff --git a/src/sbin/lorax-composer b/src/sbin/lorax-composer index 89e65b4b..f644574b 100755 --- a/src/sbin/lorax-composer +++ b/src/sbin/lorax-composer @@ -34,8 +34,6 @@ from threading import Lock from gevent import socket from gevent.wsgi import WSGIServer -from pyanaconda.queue import QueueFactory - from pylorax import vernum from pylorax.api.config import configure, make_yum_dirs from pylorax.api.queue import monitor @@ -219,10 +217,8 @@ if __name__ == '__main__': listener.listen(1) # Start queue monitor thread as root - cancel_q = QueueFactory("cancel") - cancel_q.addMessage("cancel", 0) cfg = DataHolder(composer_dir=lib_dir, uid=uid, gid=gid) - p = mp.Process(target=monitor, args=(cfg, cancel_q)) + p = mp.Process(target=monitor, args=(cfg,)) p.daemon = True p.start()