Skip to content

Commit

Permalink
fix!: Terminating all VFS processes when cleaning up session (#149)
Browse files Browse the repository at this point in the history
* fix!: Terminating all VFS processes when cleaning up session
---------

Signed-off-by: Nathan Matthews <natmatn@amazon.com>
  • Loading branch information
natmatn committed Feb 21, 2024
1 parent 1acfffc commit 50178ed
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
dependencies = [
"requests ~= 2.31",
"boto3 >= 1.28.80",
"deadline == 0.37.*",
"deadline == 0.38.*",
"openjd-sessions == 0.5.*",
# tomli became tomllib in standard library in Python 3.11
"tomli == 2.0.* ; python_version<'3.11'",
Expand Down
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(
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

0 comments on commit 50178ed

Please sign in to comment.