"""Free-space accounting across the filesystems a pull can fill. docker 29 keeps image layers in containerd's store, which is frequently on a different filesystem than DockerRootDir. env-dev-08 (2026-09-09) had 93 GiB free on the data-root and 2.8 GiB on the filesystem containerd was writing to; the pull died with "no space left on device" after the pre-flight had reported plenty of room. """ from __future__ import annotations import monky_deployd.compose as compose_mod from monky_deployd.compose import Docker class _FixedDocker(Docker): def __init__(self, root: str): super().__init__() self._root = root def data_root(self) -> str: return self._root def test_storage_paths_include_containerd_root_when_present(tmp_path, monkeypatch): root = tmp_path / "docker" containerd = tmp_path / "containerd" root.mkdir() containerd.mkdir() monkeypatch.setattr(compose_mod, "CONTAINERD_ROOTS", (str(containerd),)) assert _FixedDocker(str(root)).storage_paths() == [str(root), str(containerd)] def test_storage_paths_skip_a_containerd_root_that_does_not_exist(tmp_path, monkeypatch): root = tmp_path / "docker" root.mkdir() monkeypatch.setattr(compose_mod, "CONTAINERD_ROOTS", (str(tmp_path / "absent"),)) assert _FixedDocker(str(root)).storage_paths() == [str(root)] def test_free_bytes_reports_the_tightest_filesystem(tmp_path, monkeypatch): root = tmp_path / "docker" containerd = tmp_path / "containerd" root.mkdir() containerd.mkdir() monkeypatch.setattr(compose_mod, "CONTAINERD_ROOTS", (str(containerd),)) d = _FixedDocker(str(root)) monkeypatch.setattr(d, "_free_at", lambda p: 900 if p == str(root) else 5) assert d.free_bytes() == 5 # an explicit path is still measured on its own assert d.free_bytes(str(root)) == 900 def test_free_bytes_is_none_when_nothing_can_be_measured(tmp_path, monkeypatch): root = tmp_path / "docker" root.mkdir() monkeypatch.setattr(compose_mod, "CONTAINERD_ROOTS", ()) d = _FixedDocker(str(root)) monkeypatch.setattr(d, "_free_at", lambda p: None) assert d.free_bytes() is None