Skip to content

Commit ac5e34e

Browse files
committed
fix(e2e): repair podman harness on macOS
Podman 5.x with the applehv/libkrun provider no longer creates the legacy ~/.local/share/containers/podman/machine/podman.sock symlink, and `podman system service` is a Linux-only subcommand — the macOS client delegates the API service to the VM. Both assumptions in the harness were stale, so the script tried to start a temporary service that podman rejected with "unknown flag: --time". - Discover the macOS socket via `podman machine inspect` instead of the hardcoded path. - On Darwin, fail fast with a "start podman machine" message rather than attempting the Linux-only `podman system service` fallback. - Write socket_path into [openshell.drivers.podman] so the in-process driver picks up the discovered socket; the driver reads TOML only after the config refactor (560550d), so OPENSHELL_PODMAN_SOCKET alone was no longer enough.
1 parent 42a96bd commit ac5e34e

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

‎e2e/with-podman-gateway.sh‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ ensure_e2e_podman_network() {
144144
default_podman_socket_path() {
145145
case "$(uname -s)" in
146146
Darwin)
147-
printf '%s\n' "${HOME}/.local/share/containers/podman/machine/podman.sock"
147+
# On macOS the podman client talks to a VM; the API socket path is
148+
# per-launch (under $TMPDIR) and reported by `podman machine inspect`.
149+
# The legacy ~/.local/share/containers/podman/machine/podman.sock path
150+
# is not created by podman >= 5.x with the applehv/libkrun providers.
151+
podman_cmd machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}' 2>/dev/null \
152+
| awk 'NF { print; exit }'
148153
;;
149154
Linux)
150155
if [ -n "${XDG_RUNTIME_DIR:-}" ]; then
@@ -165,13 +170,26 @@ ensure_podman_api_socket() {
165170
fi
166171

167172
local default_socket
168-
if default_socket="$(default_podman_socket_path)" \
173+
default_socket="$(default_podman_socket_path || true)"
174+
if [ -n "${default_socket}" ] \
169175
&& [ -S "${default_socket}" ] \
170176
&& podman_cmd --url "unix://${default_socket}" info >/dev/null 2>&1; then
171177
export OPENSHELL_PODMAN_SOCKET="${default_socket}"
172178
return 0
173179
fi
174180

181+
# `podman system service` is a Linux-only subcommand — the macOS client
182+
# delegates the API service to the VM, so we can't spin one up locally.
183+
# If we got here on Darwin, the user's `podman machine` is either not
184+
# running or its socket isn't reachable; surface that directly.
185+
if [ "$(uname -s)" = "Darwin" ]; then
186+
echo "ERROR: could not reach the Podman API socket on macOS." >&2
187+
echo " Expected socket from 'podman machine inspect': ${default_socket:-<none>}" >&2
188+
echo " Ensure 'podman machine start' has been run, or set" >&2
189+
echo " OPENSHELL_PODMAN_SOCKET to a reachable unix socket path." >&2
190+
exit 2
191+
fi
192+
175193
PODMAN_SOCKET="${WORKDIR}/podman/podman.sock"
176194
mkdir -p "$(dirname "${PODMAN_SOCKET}")"
177195

@@ -348,6 +366,14 @@ GATEWAY_CONFIG="${STATE_DIR}/gateway.toml"
348366
printf 'default_image = %s\n' "$(toml_string "${SANDBOX_IMAGE}")"
349367
printf 'image_pull_policy = "missing"\n'
350368
printf 'supervisor_image = %s\n' "$(toml_string "${SUPERVISOR_IMAGE}")"
369+
# The in-process Podman driver reads `socket_path` from TOML only — the
370+
# OPENSHELL_PODMAN_SOCKET env var is honoured by the standalone driver
371+
# binary, not the in-process driver used here. Pin the socket to the one
372+
# the harness discovered (e.g. via `podman machine inspect` on macOS) so
373+
# we don't fall back to the driver's stale macOS default.
374+
if [ -n "${OPENSHELL_PODMAN_SOCKET:-}" ]; then
375+
printf 'socket_path = %s\n' "$(toml_string "${OPENSHELL_PODMAN_SOCKET}")"
376+
fi
351377
} > "${GATEWAY_CONFIG}"
352378

353379
GATEWAY_ARGS=(

0 commit comments

Comments
 (0)