Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(host-agent): leave bind-mounted files out of data-folder pre-creation (#8256)

Mike Bradley25d0c112f548
diff --git a/ods/bin/ods-host-agent.py b/ods/bin/ods-host-agent.py
index d42f0ed5a..ac85b67ff 100755
--- a/ods/bin/ods-host-agent.py
+++ b/ods/bin/ods-host-agent.py
@@ -6834,6 +6834,10 @@ def _precreate_compose_data_dirs(service_id: str, ext_dir: Path, compose_path: P
except ValueError:
logger.warning("Skipping out-of-tree volume path in %s: %s", service_id, vol_str)
continue
+ # A file the extension ships (Whisper's docker-entrypoint.sh) is not
+ # a data directory; mkdir on it logged "File exists" on every start.
+ if dir_path.exists() and not dir_path.is_dir():
+ continue
try:
dir_path.mkdir(parents=True, exist_ok=True)
# Native Windows Python has no os.getuid (or POSIX owners);
diff --git a/ods/extensions/services/dashboard-api/tests/test_host_agent.py b/ods/extensions/services/dashboard-api/tests/test_host_agent.py
index 726988a87..575fc4a0a 100644
--- a/ods/extensions/services/dashboard-api/tests/test_host_agent.py
+++ b/ods/extensions/services/dashboard-api/tests/test_host_agent.py
@@ -7697,6 +7697,36 @@ class TestPrecreateDataDirs:
assert (install_dir / "upload").is_dir()
assert (install_dir / "data" / "state").is_dir()
+ def test_leaves_a_bind_mounted_file_alone(self, tmp_path, monkeypatch, caplog):
+ """Whisper bind-mounts its docker-entrypoint.sh; mkdir on that file logged
+ "Failed to pre-create ... File exists" on every start (Workstation06)."""
+ pytest.importorskip("yaml")
+ user_root = tmp_path / "user"
+ builtin_root = tmp_path / "builtin"
+ install_dir = tmp_path / "install"
+ user_root.mkdir()
+ builtin_root.mkdir()
+ install_dir.mkdir()
+ ext_dir = builtin_root / "svc-f"
+ self._write_compose(ext_dir, [
+ "./extensions/services/svc-f/docker-entrypoint.sh:/app/docker-entrypoint.sh:ro",
+ "./data/svc-f:/cache",
+ ])
+ entrypoint = install_dir / "extensions" / "services" / "svc-f" / "docker-entrypoint.sh"
+ entrypoint.parent.mkdir(parents=True)
+ entrypoint.write_text("#!/bin/sh\n", encoding="utf-8")
+
+ monkeypatch.setattr(_mod, "EXTENSIONS_DIR", builtin_root)
+ monkeypatch.setattr(_mod, "USER_EXTENSIONS_DIR", user_root)
+ monkeypatch.setattr(_mod, "INSTALL_DIR", install_dir)
+
+ with caplog.at_level("WARNING"):
+ _mod._precreate_data_dirs("svc-f")
+
+ assert entrypoint.read_text(encoding="utf-8") == "#!/bin/sh\n"
+ assert (install_dir / "data" / "svc-f").is_dir()
+ assert "Failed to pre-create" not in caplog.text
+
def test_manifest_container_uid_fallback_chowns_when_root(
self, tmp_path, monkeypatch,
):