diff --git a/lorax-composer.spec b/lorax-composer.spec index d6ea915d..50bc4f9a 100644 --- a/lorax-composer.spec +++ b/lorax-composer.spec @@ -19,7 +19,7 @@ BuildRequires: python2-devel BuildRequires: python-sphinx yum python-mako pykickstart BuildRequires: python-flask python-gobject libgit2-glib python2-pytoml python-semantic_version -Requires: lorax >= 19.7.16 +Requires: lorax >= 19.7.20 Requires(pre): /usr/bin/getent Requires(pre): /usr/sbin/groupadd Requires(pre): /usr/sbin/useradd diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index d3c711f9..68f701db 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -433,7 +433,7 @@ def uuid_cancel(cfg, uuid): # It can move from WAITING -> RUNNING or it can move from RUNNING -> FINISHED|FAILED # If it is in WAITING remove the symlink and then check to make sure it didn't show up - # in RUNNING + # in the run queue queue_dir = joinpaths(cfg.get("composer", "lib_dir"), "queue") uuid_new = joinpaths(queue_dir, "new", uuid) if os.path.exists(uuid_new): @@ -444,10 +444,13 @@ def uuid_cancel(cfg, uuid): pass uuid_run = joinpaths(queue_dir, "run", uuid) if not os.path.exists(uuid_run): - # Successfully removed it before the build started - return uuid_delete(cfg, uuid) + # Make sure the build is still in the waiting state + status = uuid_status(cfg, uuid) + if status is None or status["queue_status"] == "WAITING": + # Successfully removed it before the build started + return uuid_delete(cfg, uuid) - # Tell the build to stop running + # At this point the build has probably started. Write to the CANCEL file. open(cancel_path, "w").write("\n") # Wait for status to move to FAILED or FINISHED @@ -457,6 +460,7 @@ def uuid_cancel(cfg, uuid): if status is None or status["queue_status"] == "FAILED": break elif status is not None and status["queue_status"] == "FINISHED": + # The build finished successfully, no point in deleting it now return False # Is this taking too long? Exit anyway and try to cleanup.