Add missing checks on return value from uuid_status
This commit is contained in:
parent
97eb262d1e
commit
c58e1994e9
@ -385,7 +385,7 @@ def uuid_cancel(cfg, uuid):
|
|||||||
started = time.time()
|
started = time.time()
|
||||||
while True:
|
while True:
|
||||||
status = uuid_status(cfg, uuid)
|
status = uuid_status(cfg, uuid)
|
||||||
if status["queue_status"] == "FAILED":
|
if status is None or status["queue_status"] == "FAILED":
|
||||||
break
|
break
|
||||||
|
|
||||||
# Is this taking too long? Exit anyway and try to cleanup.
|
# 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
|
# 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
|
# has finished they will be in the results directory
|
||||||
status = uuid_status(cfg, uuid)
|
status = uuid_status(cfg, uuid)
|
||||||
|
if status is None:
|
||||||
|
raise RuntimeError("Status is missing for %s" % uuid)
|
||||||
|
|
||||||
if status["queue_status"] == "RUNNING":
|
if status["queue_status"] == "RUNNING":
|
||||||
log_path = "/tmp/anaconda.log"
|
log_path = "/tmp/anaconda.log"
|
||||||
else:
|
else:
|
||||||
|
@ -1585,7 +1585,9 @@ def v0_api(api):
|
|||||||
return jsonify(status=False, error={"msg":str(e)}), 400
|
return jsonify(status=False, error={"msg":str(e)}), 400
|
||||||
|
|
||||||
status = uuid_status(api.config["COMPOSER_CFG"], uuid)
|
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")
|
return jsonify(status=False, uuid=uuid, msg="Build has not started yet. No logs to view")
|
||||||
try:
|
try:
|
||||||
return Response(uuid_log(api.config["COMPOSER_CFG"], uuid, size), direct_passthrough=True)
|
return Response(uuid_log(api.config["COMPOSER_CFG"], uuid, size), direct_passthrough=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user