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(dashboard-api): keep Open WebUI's off switch when .env is unreadable (#8237)

Mike Bradleye47f843b9f10
diff --git a/ods/docker-compose.base.yml b/ods/docker-compose.base.yml
index af4c32d33..cee94996d 100644
--- a/ods/docker-compose.base.yml
+++ b/ods/docker-compose.base.yml
@@ -281,6 +281,10 @@ services:
- ODS_DATA_DIR=/data
- ODS_EXTENSIONS_LIBRARY_DIR=/data/extensions-library
- ODS_MODE=${ODS_MODE:-local}
+ # Service status reads this live from .env. An install owner other than
+ # UID 1000 leaves the 0600 .env unreadable here, and the status must then
+ # fall back to this copy instead of counting Open WebUI as a core service down.
+ - ENABLE_OPEN_WEBUI=${ENABLE_OPEN_WEBUI:-true}
- ODS_AGENT_HOST=${ODS_AGENT_HOST:-}
- ODS_AGENT_PORT=${ODS_AGENT_PORT:-7710}
- GPU_BACKEND=${GPU_BACKEND:-nvidia}
diff --git a/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py b/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
index 53537ae3d..de0d0f3dd 100644
--- a/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
+++ b/ods/extensions/services/dashboard-api/tests/test_compose_env_mount.py
@@ -10,3 +10,12 @@ def test_dashboard_api_mounts_env_parent_instead_of_replaceable_file():
assert "./:/ods:ro,z" in volumes
assert not any(volume.startswith("./.env:/ods/.env:") for volume in volumes)
+
+
+def test_dashboard_api_receives_the_open_webui_switch_for_an_unreadable_env():
+ # DGX Station: the install owner is UID 1001, the API runs as 1000, so the
+ # 0600 .env is unreadable and only this copy says Open WebUI is switched off.
+ compose = Path(__file__).resolve().parents[4] / "docker-compose.base.yml"
+ service = yaml.safe_load(compose.read_text(encoding="utf-8"))["services"]["dashboard-api"]
+
+ assert "ENABLE_OPEN_WEBUI=${ENABLE_OPEN_WEBUI:-true}" in service["environment"]
diff --git a/ods/extensions/services/dashboard-api/tests/test_helpers.py b/ods/extensions/services/dashboard-api/tests/test_helpers.py
index 933412e47..9562019b7 100644
--- a/ods/extensions/services/dashboard-api/tests/test_helpers.py
+++ b/ods/extensions/services/dashboard-api/tests/test_helpers.py
@@ -772,6 +772,42 @@ class TestGetAllServices:
assert [item.status for item in result] == [expected]
assert probed == ([] if expected == "not_deployed" else ["open-webui"])
+ @pytest.mark.asyncio
+ async def test_open_webui_switched_off_reads_not_deployed_when_env_file_is_unreadable(self, monkeypatch, tmp_path):
+ # DGX Station: the install owner is UID 1001 and the API runs as 1000, so
+ # the 0600 .env is unreadable and the overview read "8/9 core services online".
+ # The switch then comes from the process environment Compose passes.
+ import config
+ monkeypatch.setattr(config, "INSTALL_DIR", str(tmp_path))
+ config._reset_env_permission_state()
+ env_file = tmp_path / ".env"
+ env_file.write_text("ENABLE_OPEN_WEBUI=true\n", encoding="utf-8")
+ read_text = Path.read_text
+
+ def denied(path, *args, **kwargs):
+ if path == env_file:
+ raise PermissionError("Simulated EACCES on .env")
+ return read_text(path, *args, **kwargs)
+
+ monkeypatch.setattr(Path, "read_text", denied)
+ monkeypatch.setenv("ENABLE_OPEN_WEBUI", "false")
+ monkeypatch.setattr("helpers.load_extension_manifests", lambda *args, **kwargs: ({}, [], []))
+ monkeypatch.setattr("helpers.SERVICES", {"open-webui": {
+ "name": "Open WebUI (Chat)", "port": 8080, "external_port": 3000, "health": "/health", "host": "open-webui"}})
+ probed: list[str] = []
+
+ async def fake_health(sid, cfg):
+ probed.append(sid)
+ return ServiceStatus(id=sid, name=cfg["name"], port=cfg["port"],
+ external_port=cfg["external_port"], status="down")
+
+ monkeypatch.setattr("helpers.check_service_health", fake_health)
+ monkeypatch.setattr("helpers.request_agent_json", AsyncMock(side_effect=ValueError("no agent")))
+ result = await get_all_services()
+ assert [item.status for item in result] == ["not_deployed"]
+ assert probed == []
+ assert config.get_env_file_read_error() is not None
+
@pytest.mark.asyncio
async def test_empty_services_returns_empty(self, monkeypatch):
monkeypatch.setattr("helpers.load_extension_manifests", lambda *args, **kwargs: ({}, [], []))