Add missing checks on return value from uuid_status

This commit is contained in:
Brian C. Lane 2018-03-22 15:23:44 -07:00
parent 97eb262d1e
commit c58e1994e9
2 changed files with 7 additions and 2 deletions

View File

@ -385,7 +385,7 @@ def uuid_cancel(cfg, uuid):
started = time.time()
while True:
status = uuid_status(cfg, uuid)
if status["queue_status"] == "FAILED":
if status is None or status["queue_status"] == "FAILED":
break
# Is this taking too long? Exit anyway and try to cleanup.
@ -565,6 +565,9 @@ def uuid_log(cfg, uuid, size=1024):
# While a build is running the logs will be in /tmp/anaconda.log and when it
# has finished they will be in the results directory
status = uuid_status(cfg, uuid)
if status is None:
raise RuntimeError("Status is missing for %s" % uuid)
if status["queue_status"] == "RUNNING":
log_path = "/tmp/anaconda.log"
else:

View File

@ -1585,7 +1585,9 @@ def v0_api(api):
return jsonify(status=False, error={"msg":str(e)}), 400
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
if status is None or status["queue_status"] == "WAITING":
if status is None:
return jsonify(status=False, error={"msg":"%s is not a valid build uuid" % uuid}), 400
elif status["queue_status"] == "WAITING":
return jsonify(status=False, uuid=uuid, msg="Build has not started yet. No logs to view")
try:
return Response(uuid_log(api.config["COMPOSER_CFG"], uuid, size), direct_passthrough=True)