Skip to content

Commit de0ff03

Browse files
authored
Merge pull request #199 from NYU-RTS/slurmrest-updates
delete jobs as root
2 parents 7e6af1d + e099c70 commit de0ff03

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

coldfront/plugins/slurmrest/utils.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,19 @@ def delete_association_user_account(self, username: str, account: str, noop: boo
9191
logging.info(f"noop enabled: skip deleting association between user: {username} and acconut: {account}")
9292
return
9393

94-
# for some operations, instantiate a user client when possible
95-
# note that this needs the X-SLURM-USER-NAME header upon instantiation
96-
this_user_client: Client = Client(
97-
base_url=self.endpoint,
98-
headers={
99-
"X-SLURM-USER-NAME": f"{username}",
100-
"X-SLURM-USER-TOKEN": self.token,
101-
},
102-
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
103-
)
104-
105-
with this_user_client as client:
106-
# start by deleting active jobs for this user
107-
body_job_kill: V0043KillJobsMsg = V0043KillJobsMsg(user_name=username, account=account)
108-
jobs_delete_resp = slurm_v0043_delete_jobs.sync(client=client, body=body_job_kill)
109-
if jobs_delete_resp:
110-
deletion_statuses: list[V0043KillJobsRespJob] = jobs_delete_resp.status
111-
for status in deletion_statuses:
112-
logging.debug(f"deletion status: {status}")
113-
if jobs_delete_resp.errors:
114-
for error in jobs_delete_resp.errors:
115-
logging.error(f"error deleting job: {error}")
116-
raise RuntimeError(f"Could not delete jobs for user: {username} with account: {account}")
117-
else:
118-
raise ConnectionError(f"Could not delete jobs for user: {username} with account: {account}")
94+
# start by deleting active jobs for this user
95+
body_job_kill: V0043KillJobsMsg = V0043KillJobsMsg(user_name=username, account=account)
96+
jobs_delete_resp = slurm_v0043_delete_jobs.sync(client=self.root_client, body=body_job_kill)
97+
if jobs_delete_resp:
98+
deletion_statuses: list[V0043KillJobsRespJob] = jobs_delete_resp.status
99+
for status in deletion_statuses:
100+
logging.debug(f"deletion status: {status}")
101+
if jobs_delete_resp.errors:
102+
for error in jobs_delete_resp.errors:
103+
logging.error(f"error deleting job: {error}")
104+
raise RuntimeError(f"Could not delete jobs for user: {username} with account: {account}")
105+
else:
106+
raise ConnectionError(f"Could not delete jobs for user: {username} with account: {account}")
119107

120108
# set maxsubmit to 0 as root
121109
max_submit_assoc: V0043Assoc = V0043Assoc(

0 commit comments

Comments
 (0)