Check for existing CANCEL request, and exit on FINISHED
If another CANCEL request has already been made just exit from
uuid_cancel. If the build is FINISHED before it times out just exit,
don't remove the finished results.
(cherry picked from commit 962d10b3b7
)
Related: rhbz#1659129
This commit is contained in:
parent
48c8ae6819
commit
0baa524d8d
@ -424,6 +424,11 @@ def uuid_cancel(cfg, uuid):
|
|||||||
|
|
||||||
Only call this if the build status is WAITING or RUNNING
|
Only call this if the build status is WAITING or RUNNING
|
||||||
"""
|
"""
|
||||||
|
cancel_path = joinpaths(cfg.get("composer", "lib_dir"), "results", uuid, "CANCEL")
|
||||||
|
if os.path.exists(cancel_path):
|
||||||
|
log.info("Cancel has already been requested for %s", uuid)
|
||||||
|
return False
|
||||||
|
|
||||||
# This status can change (and probably will) while it is in the middle of doing this:
|
# This status can change (and probably will) while it is in the middle of doing this:
|
||||||
# It can move from WAITING -> RUNNING or it can move from RUNNING -> FINISHED|FAILED
|
# It can move from WAITING -> RUNNING or it can move from RUNNING -> FINISHED|FAILED
|
||||||
|
|
||||||
@ -443,15 +448,16 @@ def uuid_cancel(cfg, uuid):
|
|||||||
return uuid_delete(cfg, uuid)
|
return uuid_delete(cfg, uuid)
|
||||||
|
|
||||||
# Tell the build to stop running
|
# Tell the build to stop running
|
||||||
cancel_path = joinpaths(cfg.get("composer", "lib_dir"), "results", uuid, "CANCEL")
|
|
||||||
open(cancel_path, "w").write("\n")
|
open(cancel_path, "w").write("\n")
|
||||||
|
|
||||||
# Wait for status to move to FAILED
|
# Wait for status to move to FAILED or FINISHED
|
||||||
started = time.time()
|
started = time.time()
|
||||||
while True:
|
while True:
|
||||||
status = uuid_status(cfg, uuid)
|
status = uuid_status(cfg, uuid)
|
||||||
if status is None or status["queue_status"] == "FAILED":
|
if status is None or status["queue_status"] == "FAILED":
|
||||||
break
|
break
|
||||||
|
elif status is not None and status["queue_status"] == "FINISHED":
|
||||||
|
return False
|
||||||
|
|
||||||
# Is this taking too long? Exit anyway and try to cleanup.
|
# Is this taking too long? Exit anyway and try to cleanup.
|
||||||
if time.time() > started + (10 * 60):
|
if time.time() > started + (10 * 60):
|
||||||
|
Loading…
Reference in New Issue
Block a user