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.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(comfyui): prepare UID 1000 data folders for a Dashboard add-back (#8252)
Mike Bradley77ee2e59b1d4
diff --git a/ods/bin/ods-host-agent.py b/ods/bin/ods-host-agent.pyindex f368a24a4..d42f0ed5a 100755--- a/ods/bin/ods-host-agent.py+++ b/ods/bin/ods-host-agent.py@@ -6898,6 +6898,15 @@ def _repair_rootless_data_ownership(service_id: str) -> None:bash, "-c", 'source "$1"; ods_prepare_service_state_ownership "$2" "$3"',"ods-service-state", str(helper), str(INSTALL_DIR), service_id,]+ elif service_id == "comfyui":+ # Phase 11 prepares ComfyUI's UID 1000 bind sources only when it is+ # enabled at install. A Dashboard add-back on rootful Docker under+ # another owner UID crash-looped on mkdir /models/text_encoders+ # (Workstation06, 2026-10-26). The backend picks the image's layout.+ command = [+ bash, "-c", 'source "$1"; ods_prepare_comfyui_data_ownership "$2" "$3"',+ "ods-comfyui-data", str(helper), str(INSTALL_DIR), GPU_BACKEND,+ ]try:result = subprocess.run(command,diff --git a/ods/extensions/services/dashboard-api/tests/test_host_agent.py b/ods/extensions/services/dashboard-api/tests/test_host_agent.pyindex 82bdb43cb..726988a87 100644--- a/ods/extensions/services/dashboard-api/tests/test_host_agent.py+++ b/ods/extensions/services/dashboard-api/tests/test_host_agent.py@@ -7908,6 +7908,32 @@ class TestRootlessDataOwnershipRepair:"ods-service-state", str(helper), str(tmp_path), service_id,]]+ def test_comfyui_uses_rootful_or_rootless_data_preparation(self, tmp_path, monkeypatch):+ """A Dashboard add-back on Workstation06 (owner UID 1001) crash-looped on+ mkdir /models/text_encoders: Phase 11 prepares these folders only at install."""+ helper = tmp_path / "lib" / "rootless-ownership.sh"+ helper.parent.mkdir()+ helper.write_text("#!/usr/bin/env bash\n", encoding="utf-8")+ calls = []+ monkeypatch.setattr(_mod, "INSTALL_DIR", tmp_path)+ monkeypatch.setattr(_mod, "GPU_BACKEND", "nvidia")+ monkeypatch.setattr(_mod.platform, "system", lambda: "Linux")+ monkeypatch.setattr(_mod, "_find_usable_bash", lambda: "/bin/bash")++ def fake_run(cmd, **kwargs):+ calls.append(cmd)+ return subprocess.CompletedProcess(cmd, 0, "", "")++ monkeypatch.setattr(_mod.subprocess, "run", fake_run)++ _mod._repair_rootless_data_ownership("comfyui")++ assert calls == [[+ "/bin/bash", "-c",+ 'source "$1"; ods_prepare_comfyui_data_ownership "$2" "$3"',+ "ods-comfyui-data", str(helper), str(tmp_path), "nvidia",+ ]]+def test_runs_targeted_helper_for_builtin_linux_service(self, tmp_path, monkeypatch,):diff --git a/ods/lib/rootless-ownership.sh b/ods/lib/rootless-ownership.shindex 73d4666eb..3e8420e42 100644--- a/ods/lib/rootless-ownership.sh+++ b/ods/lib/rootless-ownership.sh@@ -456,6 +456,48 @@ ods_prepare_service_state_ownership() {"Stop it with 'ods stop $service', then choose Retry on its card in Extensions."}+# ComfyUI's NVIDIA image runs as UID 1000. Phase 11 prepares its writable bind+# sources only when ComfyUI is enabled at install, and the namespace repair+# above is a no-op on rootful Docker, so a Dashboard or Library add-back must do+# the same before the first start. An install owner with another UID otherwise+# leaves them read-only to the container, which crash-looped on+# mkdir /models/text_encoders (Workstation06, 2026-10-26: owner UID 1001). As in+# Phase 11, the owner's group keeps write access for the model packs the host+# agent downloads. A folder that already matches is left alone without Docker.+ods_prepare_comfyui_data_ownership() {+ local install_dir="$1" backend="${2:-}" rootless_state=0 host_uid host_gid path target metadata+ [[ -n "$install_dir" && "$(uname -s)" == Linux ]] || return 1+ ods_docker_rootless_state || rootless_state=$?+ case "$rootless_state" in+ 0) GPU_BACKEND="$backend" ods_fix_rootless_ownership "$install_dir" comfyui; return ;;+ 1) ;;+ *) return 1 ;;+ esac+ # Only the NVIDIA image runs as UID 1000 against these folders.+ [[ "$backend" == nvidia ]] || return 0+ host_uid=$(id -u) || return 1+ [[ "$host_uid" != 1000 ]] || return 0+ host_gid=$(id -g) || return 1+ [[ "$host_gid" =~ ^[0-9]+$ ]] || return 1+ for path in models output input user; do+ [[ -d "$install_dir/data/comfyui/$path" && ! -L "$install_dir/data/comfyui/$path" ]] || {+ echo "[error] The ComfyUI $path folder is not a real directory." >&2+ return 1+ }+ metadata=$(stat -c '%u:%g' "$install_dir/data/comfyui/$path") || return 1+ [[ "$metadata" != "1000:$host_gid" ]] || continue+ _ods_rootless_ensure_helper_image || return 1+ _ods_rootless_fix_directory "$install_dir" "data/comfyui/$path" "1000:$host_gid" ods-comfyui 775 \+ "Stop it with 'ods stop comfyui', then choose Retry on its card in Extensions." || return 1+ target=$(_ods_rootless_resolve_target "$install_dir" "data/comfyui/$path") || return 1+ docker run --rm --pull never --user 0:0 --network none -v "$target:/data" \+ "$ODS_ROOTLESS_HELPER_IMAGE" chmod -R ug+rwX /data || {+ echo "[error] Could not make data/comfyui/$path writable for ComfyUI and the install group." >&2+ return 1+ }+ done+}+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; thenods_fix_rootless_ownership "${1:-}" "${2:-}"fidiff --git a/ods/tests/test-rootless-docker-ownership.sh b/ods/tests/test-rootless-docker-ownership.shindex a422e6d81..ccd3997f3 100644--- a/ods/tests/test-rootless-docker-ownership.sh+++ b/ods/tests/test-rootless-docker-ownership.sh@@ -271,6 +271,64 @@ pass "a rootful APE refusal names the stop-and-retry remedy"|| fail "rootless APE add-back did not keep its namespace repair, or another service was accepted: $(cat "$CALLS")"pass "rootless APE add-back keeps its namespace repair; other services are refused"+# Workstation06 (2026-10-26): the install owner is UID 1001 and ComfyUI was+# added from the Dashboard, so Phase 11 never prepared its UID 1000 folders.+mkdir -p "$INSTALL_DIR/data/comfyui"/{models,output,input,user}+: > "$CALLS"+(+ source "$LIB"+ ods_docker_rootless_state() { return 1; }+ uname() { printf 'Linux\n'; }+ id() { case "$1" in -u) printf '1001\n' ;; -g) printf '4242\n' ;; esac; }+ stat() { printf '1001:4242\n'; }+ _ods_rootless_ensure_helper_image() { :; }+ _ods_rootless_resolve_target() { printf '%s/%s\n' "$1" "$2"; }+ _ods_rootless_fix_directory() { printf 'fix %s|%s|%s|%s\n' "$2" "$3" "$4" "$5" >> "$CALLS"; }+ docker() { printf 'docker %s\n' "$*" >> "$CALLS"; }+ ods_prepare_comfyui_data_ownership "$INSTALL_DIR" nvidia+) || fail "rootful ComfyUI add-back preparation failed: $(cat "$CALLS")"+for path in models output input user; do+ grep -qx "fix data/comfyui/$path|1000:4242|ods-comfyui|775" "$CALLS" \+ || fail "rootful ComfyUI add-back did not prepare data/comfyui/$path for UID 1000: $(cat "$CALLS")"+ grep -q "^docker run .* -v $INSTALL_DIR/data/comfyui/$path:/data .* chmod -R ug+rwX /data\$" "$CALLS" \+ || fail "rootful ComfyUI add-back left data/comfyui/$path without the install group's write access: $(cat "$CALLS")"+done+pass "rootful ComfyUI add-back prepares its UID 1000 folders and keeps the owner group's write access"++: > "$CALLS"+(+ source "$LIB"+ ods_docker_rootless_state() { return 1; }+ uname() { printf 'Linux\n'; }+ _ods_rootless_ensure_helper_image() { printf 'helper\n' >> "$CALLS"; }+ _ods_rootless_fix_directory() { printf 'fix %s\n' "$2" >> "$CALLS"; }+ docker() { printf 'docker %s\n' "$*" >> "$CALLS"; }+ # Already prepared for this owner's group.+ id() { case "$1" in -u) printf '1001\n' ;; -g) printf '4242\n' ;; esac; }+ stat() { printf '1000:4242\n'; }+ ods_prepare_comfyui_data_ownership "$INSTALL_DIR" nvidia+ # The AMD image keeps its own layout.+ stat() { printf '1001:4242\n'; }+ ods_prepare_comfyui_data_ownership "$INSTALL_DIR" amd+ # An install owner that is UID 1000 already matches the container.+ id() { case "$1" in -u) printf '1000\n' ;; -g) printf '1000\n' ;; esac; }+ ods_prepare_comfyui_data_ownership "$INSTALL_DIR" nvidia+) || fail "a ComfyUI add-back with nothing to prepare was refused"+[[ ! -s "$CALLS" ]] || fail "a ComfyUI add-back with nothing to prepare ran Docker: $(cat "$CALLS")"+pass "ComfyUI folders that match, the AMD image and a UID 1000 owner need no repair"++: > "$CALLS"+(+ source "$LIB"+ ods_docker_rootless_state() { return 0; }+ uname() { printf 'Linux\n'; }+ ods_fix_rootless_ownership() { printf '%s|%s|%s\n' "$1" "$2" "${GPU_BACKEND:-}" >> "$CALLS"; }+ ods_prepare_comfyui_data_ownership "$INSTALL_DIR" nvidia+)+[[ "$(cat "$CALLS")" == "$INSTALL_DIR|comfyui|nvidia" ]] \+ || fail "rootless ComfyUI add-back did not keep its namespace repair for the NVIDIA image: $(cat "$CALLS")"+pass "rootless ComfyUI add-back keeps its namespace repair and passes the GPU backend"+: > "$CALLS"(source "$LIB"