Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Terminating all VFS processes when cleaning up session #149

Merged
merged 7 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/deadline_worker_agent/sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

from deadline.job_attachments.asset_sync import AssetSync
from deadline.job_attachments.asset_sync import logger as ASSET_SYNC_LOGGER
from deadline.job_attachments.exceptions import Fus3ExecutableMissingError
from deadline.job_attachments.fus3 import Fus3ProcessManager
from deadline.job_attachments.models import (
Attachments,
JobAttachmentS3Settings,
Expand Down Expand Up @@ -373,6 +375,12 @@ def _cleanup(self) -> None:
logger.info("%s successful", desc)
cur_time = monotonic()
finally:
try:
Fus3ProcessManager.find_fus3()
marofke marked this conversation as resolved.
Show resolved Hide resolved
# Shutdown all running Deadline VFS processes since session is complete
Fus3ProcessManager.kill_all_processes(session_dir=self._session.working_directory)
except Fus3ExecutableMissingError:
logger.error("Virtual File System not found, no processes to kill.")
# Clean-up the Open Job Description session
self._session.cleanup()

Expand Down
21 changes: 21 additions & 0 deletions test/unit/sessions/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ def mock_openjd_session(mock_openjd_session_cls: MagicMock) -> MagicMock:
return mock_openjd_session_cls.return_value


@pytest.fixture
def mock_fus3_process_manager_cls() -> Generator[MagicMock, None, None]:
"""Mocks the Worker Agent Session module's import of the Fus3 Process Manager class"""
with patch.object(session_mod, "Fus3ProcessManager") as mock_fus3_process_manager:
yield mock_fus3_process_manager


@pytest.fixture
def action_update_callback() -> MagicMock:
"""MagicMock action as the action update callback"""
Expand Down Expand Up @@ -1662,6 +1669,20 @@ def test_calls_openjd_cleanup(
# THEN
openjd_session_cleanup.assert_called_once_with()

def test_calls_fus3_kill(
self,
session: Session,
mock_fus3_process_manager_cls,
) -> None:
# Mock Session._monitor_action which is used to poll the Open Job Description session status
with patch.object(session, "_monitor_action", return_value=[]):
# WHEN
session._cleanup()

# THEN
mock_fus3_process_manager_cls.find_fus3.assert_called_once()
mock_fus3_process_manager_cls.kill_all_processes.assert_called()


class TestSessionStartAction:
"""Tests for Session._start_action()"""
Expand Down