Skip to content

Commit 07923fa

Browse files
committed
Improve error handling
And decode kill-cmd output logs. Signed-off-by: Vallari Agrawal <[email protected]>
1 parent 129b5e9 commit 07923fa

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Diff for: src/teuthology_api/routes/kill.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ async def create_run(
3737
except HTTPError as http_err:
3838
log.error(http_err)
3939
raise HTTPException(
40-
status_code=http_err.response.status_code, detail=repr(http_err)
40+
status_code=http_err.response.status_code, detail=str(http_err)
4141
) from http_err
4242
except Exception as err:
4343
log.error(err)
44-
raise HTTPException(status_code=500, detail=repr(err)) from err
44+
raise HTTPException(status_code=500, detail=str(err)) from err

Diff for: src/teuthology_api/services/helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def get_run_details(run_name: str):
6363
except HTTPError as http_err:
6464
log.error(http_err)
6565
raise HTTPException(
66-
status_code=http_err.response.status_code, detail=repr(http_err)
66+
status_code=http_err.response.status_code, detail=str(http_err)
6767
) from http_err
6868
except Exception as err:
6969
log.error(err)
70-
raise HTTPException(status_code=500, detail=repr(err)) from err
70+
raise HTTPException(status_code=500, detail=str(err)) from err
7171

7272

7373
def get_username(request: Request):

Diff for: src/teuthology_api/services/kill.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ async def run(args, send_logs: bool, token: dict, request: Request):
5959
)
6060
stdout, stderr = proc.communicate()
6161
returncode = proc.wait(timeout=120)
62-
log.info(stdout)
62+
output_logs = stdout.decode()
63+
log.info(output_logs)
6364
if returncode != 0:
64-
raise Exception(stdout)
65+
raise Exception(output_logs)
6566
if send_logs:
6667
return {"kill": "success", "logs": stdout}
6768
return {"kill": "success"}
6869
except Exception as exc:
6970
log.error("teuthology-kill command failed with the error: %s", repr(exc))
70-
raise HTTPException(status_code=500, detail=repr(exc)) from exc
71+
raise HTTPException(status_code=500, detail=str(exc)) from exc

Diff for: src/teuthology_api/services/suite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def run(args, send_logs: bool, access_token: str):
4343
return {"run": run_details}
4444
except Exception as exc:
4545
log.error("teuthology.suite.main failed with the error: %s", repr(exc))
46-
raise HTTPException(status_code=500, detail=repr(exc)) from exc
46+
raise HTTPException(status_code=500, detail=str(exc)) from exc
4747

4848

4949
def make_run_name(run_dic):

0 commit comments

Comments
 (0)