Skip to content

Commit

Permalink
Merge pull request #85 from canonical/cleanup-container-fs
Browse files Browse the repository at this point in the history
added container fs temporary dir cleanup in
  • Loading branch information
PietroPasotti authored Nov 22, 2023
2 parents 7a4e2cb + 811e8ea commit 2789c0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "ops-scenario"

version = "5.7"
version = "5.7.1"

authors = [
{ name = "Pietro Pasotti", email = "pietro.pasotti@canonical.com" }
Expand Down
16 changes: 15 additions & 1 deletion scenario/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,18 @@ def _get_storage_root(self, name: str, index: int) -> Path:
return storage_root

def clear(self):
"""Cleanup side effects histories."""
"""Deprecated.
Use cleanup instead.
"""
logger.warning(
"Context.clear() is deprecated and will be nuked in v6. "
"Use Context.cleanup() instead.",
)
self.cleanup()

def cleanup(self):
"""Cleanup side effects histories and reset the simulated filesystem state."""
self.juju_log = []
self.app_status_history = []
self.unit_status_history = []
Expand All @@ -308,6 +319,9 @@ def clear(self):
self._action_failure = None
self._output_state = None

self._tmp.cleanup()
self._tmp = tempfile.TemporaryDirectory()

def _record_status(self, state: "State", is_app: bool):
"""Record the previous status before a status change."""
if is_app:
Expand Down

0 comments on commit 2789c0a

Please sign in to comment.