From 87848fda231fb906155f3600808bd225695acac5 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Mon, 8 Jan 2024 16:09:36 +0530 Subject: [PATCH] services/kill: make username check case-insensitive Kill route checks if github_username == run_owner (from paddles). Github returns username "JohnDoe" while run-names scheduled via teuthology machines have no captilzation like "johndoe". This results in error like: `ERROR:teuthology_api.services.kill:JohnDoe doesn't have permission to kill a job scheduled by: johndoe` Signed-off-by: Vallari Agrawal --- src/teuthology_api/services/kill.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/teuthology_api/services/kill.py b/src/teuthology_api/services/kill.py index aa1b157..bf25547 100644 --- a/src/teuthology_api/services/kill.py +++ b/src/teuthology_api/services/kill.py @@ -24,16 +24,16 @@ def run(args, send_logs: bool, access_token: str, request: Request): run_name = args.get("--run") if run_name: run_details = get_run_details(run_name) - run_username = run_details.get("user") + run_owner = run_details.get("user") else: log.error("teuthology-kill is missing --run") raise HTTPException(status_code=400, detail="--run is a required argument") # TODO if user has admin priviledge, then they can kill any run/job. - if run_username != username: + if run_owner.lower() != username.lower(): log.error( "%s doesn't have permission to kill a job scheduled by: %s", username, - run_username, + run_owner, ) raise HTTPException( status_code=401, detail="You don't have permission to kill this run/job"