From d185c5024885a7d705dbb4818a442660adab3ff1 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Thu, 25 Apr 2024 15:15:06 +0530 Subject: [PATCH] services/kill.py: Owner can also be "scheduled_@teuthology" "scheduled_@teuthology" is the default owner name if run is scheduled from teuthology CLI tool. This commit allows users of same github username to recognize it as their jobs. Also fix how run_owner is determined. In teuthology, runs ownership is deteremined by job's "owner" and not run's "user" value. Signed-off-by: Vallari Agrawal --- src/teuthology_api/services/kill.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/teuthology_api/services/kill.py b/src/teuthology_api/services/kill.py index 3b49fd6..26410f4 100644 --- a/src/teuthology_api/services/kill.py +++ b/src/teuthology_api/services/kill.py @@ -28,12 +28,16 @@ async def run(args, send_logs: bool, access_token: dict, request: Request): run_name = args.get("--run") if run_name: run_details = get_run_details(run_name) - run_owner = run_details.get("user") + jobs_details = run_details.get("jobs", []) + if jobs_details: + run_owner = jobs_details[0].get("owner") else: log.error("teuthology-kill is missing --run") raise HTTPException(status_code=400, detail="--run is a required argument") - if run_owner.lower() != username.lower(): + if (run_owner.lower() != username.lower()) or ( + run_owner.lower() != f"scheduled_{username.lower()}@teuthology" + ): isUserAdmin = await isAdmin(username, access_token) if not isUserAdmin: log.error(