mirror of
https://github.com/piabrota/mu.git
synced 2026-11-07 06:15:59 -10:00
ygg-engine.sh says what podman said, and names a missing runtime dir, instead of guessing at a hung engine (#83)
Co-authored-by: Bruno Guilhermo de Barros Valério <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2 files changed
+31
-3
No files matched your search
@@ -25,12 +25,15 @@ sandbox:
|
||||
mounts:
|
||||
- { host: $D, engine: $T/bind }
|
||||
YAML
|
||||
# Fakes: podman answers `info` from $FAKE_ROOTLESS (true by default) or hangs when FAKE_HANG is set;
|
||||
# Fakes: podman answers `info` from $FAKE_ROOTLESS (true by default), hangs when FAKE_HANG is set, or fails
|
||||
# with FAKE_ERR on stderr (after a blank line and before a noise line) and exit 125; it logs calls to FAKE_LOG;
|
||||
# devcontainer prints $FAKE_CLI (0.89.0 by default).
|
||||
mkdir -p "$T/bin"
|
||||
cat > "$T/bin/podman" <<'EOF2'
|
||||
#!/usr/bin/env bash
|
||||
[ -z "${FAKE_LOG:-}" ] || echo "podman $*" >> "$FAKE_LOG"
|
||||
[ -z "${FAKE_HANG:-}" ] || sleep 30
|
||||
if [ -n "${FAKE_ERR:-}" ]; then printf '\n%s\nsecond line of noise\n' "$FAKE_ERR" >&2; exit 125; fi
|
||||
echo "${FAKE_ROOTLESS:-true}"
|
||||
EOF2
|
||||
cat > "$T/bin/devcontainer" <<'EOF2'
|
||||
@@ -44,6 +47,8 @@ cat > "$T/bin/mountpoint" <<'EOF2'
|
||||
EOF2
|
||||
chmod +x "$T/bin/podman" "$T/bin/devcontainer" "$T/bin/mountpoint"
|
||||
touch "$T/bind/.fake-mounted"
|
||||
mkdir -p "$T/xdg"
|
||||
export XDG_RUNTIME_DIR="$T/xdg"
|
||||
export PATH="$T/bin:$PATH" YGG_BIND="$T/bind" YGG_ENGINE_TIMEOUT=2
|
||||
|
||||
run bash "$S/ygg-engine.sh" check --folder "$D"
|
||||
@@ -69,6 +74,19 @@ FAKE_HANG=1 run bash "$S/ygg-engine.sh" check --folder "$D"
|
||||
check "check gives up on an engine that does not answer, and says to ask before restarting" \
|
||||
bash -c "[ $rc = 2 ]" && has "did not answer in 2s" && has "Ask before restarting"
|
||||
|
||||
ERRLINE='Failed to obtain podman configuration: lstat /run/user/1000: no such file or directory'
|
||||
FAKE_ERR="$ERRLINE" run bash "$S/ygg-engine.sh" check --folder "$D"
|
||||
check "check quotes podman's first error line when podman fails at once, and does not call it a hang" \
|
||||
bash -c "[ $rc = 2 ] && grep -q -F 'podman could not reach the engine at unix://$SOCK: $ERRLINE' '$T/out' && ! grep -q 'did not answer' '$T/out' && ! grep -q 'second line of noise' '$T/out'"
|
||||
|
||||
rm -f "$T/calls"
|
||||
XDG_RUNTIME_DIR="$T/no-such-xdg" FAKE_LOG="$T/calls" run bash "$S/ygg-engine.sh" check --folder "$D"
|
||||
check "check names a missing XDG_RUNTIME_DIR with both fixes, and never calls podman" \
|
||||
bash -c "[ $rc = 2 ] && grep -q -F '$T/no-such-xdg' '$T/out' && grep -q 'WSL restart' '$T/out' && grep -q -F 'mkdir -p -m 700' '$T/out' && grep -q -F '/run/user/' '$T/out' && [ ! -e '$T/calls' ] && [ ! -e '$T/no-such-xdg' ]"
|
||||
|
||||
env -u XDG_RUNTIME_DIR bash "$S/ygg-engine.sh" check --folder "$D" >"$T/out" 2>&1; rc=$?
|
||||
check "check does not mind an unset XDG_RUNTIME_DIR" bash -c "[ $rc = 0 ]" && has "answers and is rootless"
|
||||
|
||||
FAKE_CLI=0.90.0 run bash "$S/ygg-engine.sh" check --folder "$D"
|
||||
check "check refuses another devcontainer CLI version" bash -c "[ $rc = 2 ]" && has "want 0.89.0"
|
||||
|
||||
|
||||
+12
-2
@@ -44,8 +44,18 @@ unset CONTAINER_CONNECTION DOCKER_HOST
|
||||
export PATH="$dir/dc/node_modules/.bin:$PATH"
|
||||
|
||||
[ -S "$sock" ] || fail "the engine socket $sock is not there; is the Podman machine running?"
|
||||
if ! rootless="$(timeout "$wait" podman --url "$engine" info --format '{{.Host.Security.Rootless}}' 2>/dev/null)"; then
|
||||
fail "the engine at $engine did not answer in ${wait}s; the machine may be hung (a registry credential helper can wait for cloud credentials). Ask before restarting it"
|
||||
if [ -n "${XDG_RUNTIME_DIR:-}" ] && [ ! -d "$XDG_RUNTIME_DIR" ]; then
|
||||
fail "XDG_RUNTIME_DIR is $XDG_RUNTIME_DIR, but that folder does not exist, so podman cannot run (a WSL restart without a systemd user session does this). Either fix the shell: export XDG_RUNTIME_DIR=/tmp/ygg-xdg-\$(id -u); mkdir -p -m 700 \"\$XDG_RUNTIME_DIR\" or create /run/user/\$(id -u), owned by you, with mode 700"
|
||||
fi
|
||||
errf="$(mktemp)"
|
||||
rc=0
|
||||
rootless="$(timeout "$wait" podman --url "$engine" info --format '{{.Host.Security.Rootless}}' 2>"$errf")" || rc=$?
|
||||
first="$(grep -m 1 '[^[:space:]]' "$errf" || true)"; rm -f -- "$errf"
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
if [ "$rc" -eq 124 ]; then
|
||||
fail "the engine at $engine did not answer in ${wait}s; the machine may be hung (a registry credential helper can wait for cloud credentials). Ask before restarting it"
|
||||
fi
|
||||
fail "podman could not reach the engine at $engine: ${first:-no error text (exit $rc)}"
|
||||
fi
|
||||
[ "$rootless" = true ] || fail "the engine at $engine is not rootless ($rootless); the factory runs on the user socket only, never the root one"
|
||||
got="$(devcontainer --version 2>/dev/null | head -n 1 || true)"
|
||||
|
||||
Reference in new issue
Block a user