#4889 [TUI] doctor: say when the old Docker seccomp profile, not the bundled Python, is what fails
closed · @XiaoBinGan · 0 Kommentare · Auf GitHub
Server & APISecurityDocumentationWindowsLinux
Beschreibung
## Problem and result
On a Docker daemon older than 20.10, the daemon's default seccomp profile denies `access(X_OK)`, so the
launcher's `[ -x ]` test answers no for a bundled Python that is present and runs. Issue #4309 measured it four
ways: the same image and the same command start with `--security-opt seccomp=unconfined`, and without it the
container start says **"The engine in this image does not match this computer's graphics card"** and, underneath,
`strata: no usable Python found`. Both are wrong, and nothing in `strata doctor` told "the runtime is missing"
apart from "the permission test is not allowed".
After this change `strata doctor` has a container and permissions section. It says whether this process looks
like a container, and for a bundled runtime that `os.access(path, os.X_OK)` denies while an actual
`[path, "-V"]` start succeeds, it prints one sentence with the cause and the one option that fixes it; when the
two tests agree it prints only the container line. Read-only: no download, no engine start, no settings change;
the exit code and every existing check are unchanged. `--output json` adds one `container` object to the
existing report.
On this Windows checkout (not a container), `python strata.py doctor` printed:
```text
ok terminal_cli
ok monitor_tui version 8.2.8
info: PROFILE_NOT_SELECTED: select a run config or saved profile for model-specific checks
Container: no
```
For a runtime that is denied but starts, `container_lines()` prints (this is the output of that function for
the report the unit test builds):
```text
Container: yes (/.dockerenv)
/opt/strata/terminal/python/bin/python3 is present and runs (Python 3.12.15), but os.access(X_OK) says no: the default seccomp profile of a Docker daemon older than 20.10 denies access(X_OK); start the container with --security-opt seccomp=unconfined
```
## Related discussion
#4309 — the report with the four-way A/B evidence and the container-start log. Scope was posted before this
pull request: https://github.com/Niko1221/Strata/issues/4309#issuecomment-6555466830 — a read-only section in
`strata doctor`, shown by default rather than behind a new flag, because the people it helps have just been
misled and will not look for a flag. The launcher and entrypoint fix is #4312; this is the diagnostic half for
the same cause, not a competing fix.
## Approach
- `container_report()` and `container_lines()` in `strata_control/doctor.py`, called from `inspect()`;
`strata_cli/cli.py` prints the lines for `strata doctor` only, so the shared `components verify` human output
does not gain them. `--output json` carries the report.
- Container evidence: `/.dockerenv`, `/run/.containerenv`, a `container=` environment variable, `/proc/1/cgroup`
markers, and `STRATA_*` variables. The official image sets `STRATA_IN_DOCKER=1` in its runtime stage
(Dockerfile), so the image is detected from the environment it actually sets.
- The bundled runtimes are the paths `bin/strata`'s `pick_python` prefers beside the terminal packages:
`python/bin/python3`, `python/bin/python`, `python/python.exe`. `os.access` is trusted only for the positive
answer; a negative one is confirmed by actually starting the runtime with `-V`, and only "denied but runs"
prints the seccomp sentence. A runtime that cannot start is not blamed on seccomp and prints nothing extra.
- Nothing existing changes beyond added output: the report keeps its schema and `ok`, the exit code is computed
as before, and a source checkout (no bundled `python/` directory) reports `Container: no` with no runtimes.
## Validation
Python 3.11.16 on Windows; base: upstream main `c62d5e3a`.
**Passed:** `python -m pytest tests/terminal/test_doctor_container.py -q` → `4 passed in 0.19s`. The four cases:
container hints from files/environment/cgroup; access denied while the runtime starts names the old profile and
the `--security-opt seccomp=unconfined` fix; a healthy runtime and one that cannot start add no warning;
`strata doctor` prints the section and `--output json` carries it.
**Passed:** the new file with the neighbouring doctor files:
`python -m pytest tests/terminal/test_doctor_container.py tests/terminal/test_profiles.py tests/terminal/test_component_start.py tests/terminal/test_issues_022.py tests/terminal/test_archive_gaps.py tests/terminal/test_cpu_pack_avx512.py -q`
→ `77 passed, 2 skipped, 3 subtests passed in 20.74s`.
**Passed:** the A/B — with `strata_control/doctor.py` and `strata_cli/cli.py` restored to upstream main, the
new file fails 4/4 (`AttributeError: module 'strata_control.doctor' does not have the attribute
'container_report'`); with the change it is 4/4 passed.
**Passed:** the decision path with real, unmocked `os.access` and `subprocess.run`, using a real standalone
CPython copied into a fake bundled-runtime layout. `container_report(fake_root)` returned
`{"detected": false, "evidence": [], "runtimes": [{"path": "...\\python\\python.exe", "access_x_ok": true, "runs": true, "version": "Python 3.11.16", "permission_mismatch": false}]}`
and the lines were `Container: no` (no warning). With the image's `STRATA_IN_DOCKER=1` added to the
environment: `detected: true`, lines `Container: yes (STRATA_* environment (STRATA_IN_DOCKER))`, still no
warning.
**Passed:** `python strata.py doctor` printed the four lines above and exited 0; `python strata.py doctor
--output json` contained `"container": {"detected": false, "evidence": [], "runtimes": []}` and exited 0.
**Failed:** none from this change. In a wider run that also included `tests/terminal/test_recipes.py`,
`RecipeTests::test_recipe_file_cannot_inject_shell_kind_or_symlink` fails with `OSError: [WinError 1314]` (a
symlink needs a privilege this Windows account does not hold). It fails the same way on the unmodified tree, so
it is this account, not this change.
**Not run:** the case this is for — a real container on a Docker daemon older than 20.10 whose default profile
denies `access(X_OK)`. This checkout is Windows; it cannot produce that seccomp decision or run the Linux
bundled runtime, so the denial path is driven by an injected `os.access` and a mocked start in the unit tests,
not by measurement. The cause itself is #4309's evidence, which I did not reproduce here.
**Not run:** a real `strata doctor` inside the official image, and the full `tests/terminal` directory (the
doctor-family files above are the regression set for what this touches).
## Limits
- Container evidence is a heuristic: a host that exports a `STRATA_*` variable (for example `STRATA_DATA_DIR`)
is reported as `Container: yes`. That is a wording signal only; no check or exit code depends on it.
- Only the bundled runtime paths are probed, not a `STRATA_PYTHON` override or a `python3` found on PATH (the
launcher's other candidates). A host interpreter denied by the same profile but not bundled is not reported.
- Each present bundled runtime is started once (`-V`) whenever `doctor` runs: one short process start added to
a diagnostic command.
- The section explains the cause; it does not make the launcher start. On a daemon where the old profile stops
the launcher, `strata doctor` needs a way in (#4312, or a direct interpreter invocation such as
`docker run --entrypoint /opt/strata/terminal/python/bin/python3 IMAGE /opt/strata/strata.py doctor`). It is
the explanation for those hosts, not a workaround for the refusal.
- No docs change: the issue also asks for a troubleshooting entry, but I kept this PR to the command and its
tests; the docs note fits with the launcher fix (#4312) or its own docs change.
Mehr auf der Site
Links zu Install, Modellen, Releases.