Skip to content

Commit

Permalink
fix: no longer sigterm agent when running jobs as same user (#161)
Browse files Browse the repository at this point in the history
Problem:
When running jobs as the same user as the agent (i.e. the Queue's
jobsRunAs user is the same os user) the agent is SIGTERMing itself when
there is no work left for it to work on. It shouldn't be doing that.

Solution:
We were doing a /usr/bin/whoami to find out who the agent is running as,
but that output had a trailing newline that was interfering with the
check for whether the job user and agent user are the same. This fixes
that.

Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com>
  • Loading branch information
ddneilson authored Feb 16, 2024
1 parent 1a7329f commit fe12ad3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/deadline_worker_agent/scheduler/session_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def cleanup_session_user_processes(user: SessionUser):
raise NotImplementedError("Windows not supported")

# Check that the session user isn't the current user (agent user)
current_user = subprocess.check_output(["/usr/bin/whoami"], text=True)
current_user = subprocess.check_output(["/usr/bin/whoami"], text=True).strip()
if current_user == user.user:
logger.info(
f"Skipping cleaning up processes because the session user matches the agent user '{current_user}'"
Expand Down
2 changes: 1 addition & 1 deletion test/unit/scheduler/test_session_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def subprocess_check_output_mock(
with patch.object(
session_cleanup_mod.subprocess,
"check_output",
return_value=agent_user.user,
return_value=f"{agent_user.user}\n",
) as mock:
yield mock

Expand Down

0 comments on commit fe12ad3

Please sign in to comment.