Skip to content

Commit c583e81

Browse files
committed
trial-3: logs for nginx container crash failure
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent 9b0a7ba commit c583e81

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

hack/test-templates.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,18 @@ if [[ -n ${CHECKS["container-engine"]} ]]; then
397397
limactl shell "$NAME" $sudo $CONTAINER_ENGINE pull --quiet ${nginx_image}
398398
limactl shell "$NAME" $sudo $CONTAINER_ENGINE run -d --name nginx -p 127.0.0.1:8080:80 ${nginx_image}
399399

400-
if ! timeout 3m bash -euxc "until curl -f --retry 30 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"; then
401-
INFO "=== DEBUG: port forwarding failed ==="
402-
limactl shell "$NAME" $sudo $CONTAINER_ENGINE logs nginx || true
403-
limactl shell "$NAME" ss -tlnp | grep 8080 || true
404-
limactl shell "$NAME" ps aux | grep rootlesskit | grep -v grep || true
405-
limactl shell "$NAME" bash -c 'cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null' || true
406-
limactl shell "$NAME" sudo bash -c 'CHILD=$(cat /run/user/$(id -u $(logname))/containerd-rootless/child_pid 2>/dev/null) && [ -n "$CHILD" ] && echo "nsenter curl 127.0.0.1:80:" && nsenter -t "$CHILD" -n curl -sf --max-time 5 http://127.0.0.1:80 || echo "FAILED"' || true
407-
limactl shell "$NAME" sudo bash -c 'CHILD=$(cat /run/user/$(id -u $(logname))/containerd-rootless/child_pid 2>/dev/null) && [ -n "$CHILD" ] && nsenter -t "$CHILD" -n ss -tlnp' || true
408-
limactl shell "$NAME" bash -c 'echo "shell netns: $(readlink /proc/self/ns/net)"; CHILD=$(cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null); [ -n "$CHILD" ] && echo "child($CHILD) netns: $(readlink /proc/$CHILD/ns/net)"; for p in $(pgrep slirp4netns); do echo "slirp4netns($p) netns: $(readlink /proc/$p/ns/net)"; done' || true
409-
limactl shell "$NAME" curl -sf --max-time 5 http://127.0.0.1:8080 || true
410-
limactl shell "$NAME" journalctl --user -u containerd --no-pager -n 100 || true
411-
limactl shell "$NAME" bash -c 'if command -v rootlessctl >/dev/null; then rootlessctl --socket /run/user/$(id -u)/containerd-rootless/api.sock list-ports; fi' || true
400+
if ! timeout 3m bash -euxc "until curl -f --retry 15 --retry-connrefused http://127.0.0.1:8080; do sleep 3; done"; then
401+
INFO "=== DEBUG: port forwarding failed (#5030) ==="
402+
# Container state (full inspect, first 80 lines)
403+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE inspect nginx 2>&1 | head -80 || true
404+
# Container logs (stdout+stderr)
405+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE logs nginx 2>&1 || true
406+
# Run nginx in foreground to see actual startup error
407+
limactl shell "$NAME" $sudo $CONTAINER_ENGINE run --rm --name nginx-debug ${nginx_image} sh -c 'nginx -g "daemon off;" 2>&1 & PID=$!; sleep 5; kill $PID 2>/dev/null; wait $PID 2>/dev/null' || true
408+
# What's listening inside the rootlesskit child namespace
409+
limactl shell "$NAME" bash -c 'CHILD=$(cat /run/user/$(id -u)/containerd-rootless/child_pid 2>/dev/null); [ -n "$CHILD" ] && sudo nsenter -t "$CHILD" -n ss -tlnp || echo "no child_pid"' || true
410+
# Rootlesskit network driver confirmation
411+
limactl shell "$NAME" bash -c 'pgrep -a rootlesskit | head -1' || true
412412
INFO "=== END DEBUG ==="
413413
ERROR "Port forwarding to nginx container on 127.0.0.1:8080 failed"
414414
exit 1

0 commit comments

Comments
 (0)