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 6 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
6 changes: 6 additions & 0 deletions src/deadline_worker_agent/sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ def _cleanup(self) -> None:
logger.info("%s successful", desc)
cur_time = monotonic()
finally:
if self._asset_sync is not None and self._job_attachment_details is not None:
# terminate any running virtual file systems
self._asset_sync.cleanup_session( # type: ignore[attr-defined]
natmatn marked this conversation as resolved.
Show resolved Hide resolved
session_dir=self._session.working_directory,
file_system=self._job_attachment_details.job_attachments_file_system,
)
# Clean-up the Open Job Description session
self._session.cleanup()

Expand Down
25 changes: 25 additions & 0 deletions test/unit/sessions/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,31 @@ def test_calls_openjd_cleanup(
# THEN
openjd_session_cleanup.assert_called_once_with()

@pytest.fixture()
def mock_asset_sync(self, session: Session) -> Generator[MagicMock, None, None]:
with patch.object(session, "_asset_sync") as mock_asset_sync:
yield mock_asset_sync

def test_calls_asset_sync_cleanup(
self,
session: Session,
job_attachment_details: JobAttachmentDetails,
mock_asset_sync: MagicMock,
mock_openjd_session: MagicMock,
) -> None:
# GIVEN
mock_asset_sync_cleanup: MagicMock = mock_asset_sync.cleanup_session
session._job_attachment_details = job_attachment_details

# WHEN
session._cleanup()

# THEN
mock_asset_sync_cleanup.assert_called_once_with(
session_dir=mock_openjd_session.working_directory,
file_system=job_attachment_details.job_attachments_file_system,
)


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