Skip to content

Commit

Permalink
additional places I'd missed that used UTPs
Browse files Browse the repository at this point in the history
Also includes a bugfix in `check_idle.py`, I think, where master wasn't
being propagated.
  • Loading branch information
wes-turner committed Mar 16, 2024
1 parent fc5060f commit db781d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions harness/determined/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def log_in_user(args: Namespace) -> None:
password = getpass.getpass(message)

token_store = authentication.TokenStore(args.master)
utp = authentication.login(args.master, username, password, cli.cert)
token_store.set_token(utp.username, utp.token)
token_store.set_active(utp.username)
sess = authentication.login(args.master, username, password, cli.cert)
token_store.set_token(sess.username, sess.token)
token_store.set_active(sess.username)


def log_out_user(args: Namespace) -> None:
Expand Down Expand Up @@ -127,9 +127,9 @@ def change_password(args: Namespace) -> None:
# password change so that the user doesn't have to do so manually.
if args.target_user is None:
token_store = authentication.TokenStore(args.master)
utp = authentication.login(args.master, username, password, cli.cert)
token_store.set_token(utp.username, utp.token)
token_store.set_active(utp.username)
sess = authentication.login(args.master, username, password, cli.cert)
token_store.set_token(sess.username, sess.token)
token_store.set_active(sess.username)


def link_with_agent_user(args: Namespace) -> None:
Expand Down
5 changes: 2 additions & 3 deletions master/static/srv/check_idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def main():
notebook_server = f"https://127.0.0.1:{port}/proxy/{notebook_id}"
master_url = api.canonicalize_master_url(os.environ["DET_MASTER"])
cert = certs.default_load(master_url)
utp = authentication.login_with_cache(info.master_url, cert=cert)
sess = api.Session(master_url, utp, cert)
sess = authentication.login_with_cache(master_url, cert=cert)
try:
idle_type = IdleType[os.environ["NOTEBOOK_IDLE_TYPE"].upper()]
except KeyError:
Expand All @@ -92,7 +91,7 @@ def main():
idle = is_idle(notebook_server, idle_type)
sess.put(
f"/api/v1/notebooks/{notebook_id}/report_idle",
{"notebook_id": notebook_id, "idle": idle},
params={"notebook_id": notebook_id, "idle": idle},
)
except Exception:
logging.warning("ignoring error communicating with master", exc_info=True)
Expand Down
5 changes: 3 additions & 2 deletions master/static/srv/check_ready_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
check_ready_logs.py accepts a task's logs as STDIN, runs a regex to determine and report readiness.
Callers should be aware it may terminate early, and stop reading from STDIN.
"""

import argparse
import os
import re
Expand Down Expand Up @@ -36,8 +37,7 @@ def main(ready: Pattern, waiting: Optional[Pattern] = None):
cert = certs.default_load(master_url)
# This only runs on-cluster, so it is expected the username and session token are present in the
# environment.
utp = authentication.login_with_cache(master_url, cert=cert)
sess = api.Session(master_url, utp, cert)
sess = authentication.login_with_cache(master_url, cert=cert)
allocation_id = str(os.environ["DET_ALLOCATION_ID"])
for line in sys.stdin:
if ready.match(line):
Expand All @@ -47,6 +47,7 @@ def main(ready: Pattern, waiting: Optional[Pattern] = None):
post_ready(sess, allocation_id, "waiting")
return


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Read STDIN for a match and mark a task as ready")
parser.add_argument(
Expand Down

0 comments on commit db781d5

Please sign in to comment.