Skip to content

Commit

Permalink
services/kill.py: Owner can also be "scheduled_<username>@teuthology"
Browse files Browse the repository at this point in the history
"scheduled_<username>@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 <[email protected]>
  • Loading branch information
VallariAg committed Apr 25, 2024
1 parent 756cad2 commit d185c50
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/teuthology_api/services/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d185c50

Please sign in to comment.