Skip to content

fix(core): fall back to podman CLI when no API socket is found - #1858

Open
russellb wants to merge 1 commit into
NVIDIA:mainfrom
russellb:fix/podman-autodetect-cli-fallback
Open

fix(core): fall back to podman CLI when no API socket is found#1858
russellb wants to merge 1 commit into
NVIDIA:mainfrom
russellb:fix/podman-autodetect-cli-fallback

Conversation

@russellb

@russellb russellb commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Podman auto-detection only probed a fixed list of well-known socket paths. That socket is not always present — it varies by Podman version, machine provider, and platform — so on hosts where Podman is running and healthy but its socket lives elsewhere, the gateway failed to detect Podman at all.

This adds a Podman CLI fallback to detect_podman_socket(): when no well-known candidate responds, ask Podman itself where its socket is.

This repo's own e2e harness already documents the problem and works around it the same way. From e2e/with-podman-gateway.sh:

On macOS the podman client talks to a VM; the API socket path is per-launch (under $TMPDIR) and reported by podman machine inspect. The legacy ~/.local/share/containers/podman/machine/podman.sock path is not created by podman >= 5.x with the applehv/libkrun providers.

The harness shells out to podman machine inspect to find the socket. This PR moves that same capability into the product so users don't have to set OPENSHELL_PODMAN_SOCKET by hand.

Related Issue

Closes #1834

Changes

All in crates/openshell-core/src/config.rs:

  • detect_podman_socket() falls back to discover_podman_socket() when no well-known candidate responds. Every existing caller — driver auto-detection (detect_driver), the Podman driver's resolve_socket_path, and the VM driver's container-engine fallback — picks this up with no signature change.
  • discover_podman_socket() runs podman info --format json. On a local service (native Linux) it uses remoteSocket.path directly. On a remote service (macOS/Windows VM) it runs podman machine inspect to get the host-side forwarded socket, because the remoteSocket reported by podman info is the VM-internal path and is not reachable from the host.
  • Machine selection honors Podman's own connection precedence — CONTAINER_CONNECTION, then CONTAINER_HOST mapped to a connection by URI, then the containers.conf default — rather than taking the first entry from podman machine inspect. On a host with several machines, taking the first entry can point the gateway at the wrong machine's socket. An explicit endpoint that maps to no known machine is left unresolved rather than guessed; only the non-explicit default path falls back to the first entry, which is correct on the common single-machine host.
  • An explicit unix:// CONTAINER_HOST is used directly, since podman info just connected through it and a raw unix:// URL has no machine to inspect.

Docs: docs/reference/gateway-config.mdx and crates/openshell-driver-podman/README.md both described probe-only detection; updated to describe the fallback.

Rebased on #2327

This PR predates #2327 and originally also changed openshell-server/src/compute/driver_config.rs. #2327 removed the hardcoded socket_path default, made the field Option<PathBuf>, and added resolve_socket_path (explicit config wins, else detect, else config error). That made the server-side changes here unnecessary — they existed only to stop auto-detection from clobbering an operator's explicit value, which a serde default made indistinguishable from "unset." That file is no longer touched and the net diff is smaller than before.

Testing

  • mise run pre-commit passes.
  • Unit tests added/updated — 17 new tests covering podman info parsing (local, unix://-prefixed, missing, empty), podman machine inspect parsing, active-machine selection (explicit, rootful -root suffix, unmatched-explicit, default fallback), CONTAINER_HOST/CONTAINER_CONNECTION precedence, and unix:// URL parsing. cargo test -p openshell-core — 410 passed, 0 failed.
  • Functional test on macOS (Apple Silicon, Podman 5.8.2, machine 5.7.1, applehv), run against a HOME where the well-known socket path does not exist, so only the new CLI fallback can find Podman:
    • Gateway auto-detects Podman and connects: Using compute driver driver=podman, Connected to Podman cgroup_version=v2 network_backend=netavark rootless=true.
    • sandbox create reaches Ready; sandbox exec returns HELLO_FROM_SANDBOX / aarch64 / Ubuntu 24.04.3 LTS with exit code 0; sandbox delete succeeds.
    • A/B against main: a gateway built from main without this change, on the same host with the same environment and compute_drivers = ["podman"], fails to start with no responsive Podman API socket found; set OPENSHELL_PODMAN_SOCKET or configure socket_path.
    • Separately confirmed the CLI-discovered socket answers libpod/_ping with HTTP 200.
  • E2E tests added/updated (if applicable) — none added. The existing e2e:podman lane always exports OPENSHELL_PODMAN_SOCKET (via ensure_podman_api_socket), which short-circuits detection as the first candidate, so it exercises no part of this change. Covering this automatically would mean a lane that deliberately hides the well-known socket path, which depends on host Podman state.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable) — no architectural change; reference docs updated instead

@russellb
russellb requested review from a team, derekwaynecarr and mrunalp as code owners June 10, 2026 18:34
@copy-pr-bot

copy-pr-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

drew
drew previously approved these changes Jun 10, 2026
@drew

drew commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

/ok to test e068662

@elezar elezar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question I have: This seems to fix detection, but doesn't change how the gateway interacts with the podman driver? Why are no changes needed there?

@russellb

Copy link
Copy Markdown
Contributor Author

One question I have: This seems to fix detection, but doesn't change how the gateway interacts with the podman driver? Why are no changes needed there?

It's a fair question. I have podman on mac, but I don't have this problem. I was hoping the reporter would test this and see if it was enough. It seems like a reasonable change on the detection side. We go from "podman not detected at all" to either:

  1. It works (seems doubtful, but let's see ...)
  2. We detected podman is present, but we aren't finding the socket for some reason

In either case, it's more consistent with docker in this part of the code. Docker does the same thing with falling back to a CLI check at this stage.

A next improvement could be to discover the socket using podman info --format '{{.Host.RemoteSocket.Path}}' if it's not in one of the paths we expected to find it.

cc @r3v5, reporter of the issue

@r3v5

r3v5 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

One question I have: This seems to fix detection, but doesn't change how the gateway interacts with the podman driver? Why are no changes needed there?

It's a fair question. I have podman on mac, but I don't have this problem. I was hoping the reporter would test this and see if it was enough. It seems like a reasonable change on the detection side. We go from "podman not detected at all" to either:

  1. It works (seems doubtful, but let's see ...)
  2. We detected podman is present, but we aren't finding the socket for some reason

In either case, it's more consistent with docker in this part of the code. Docker does the same thing with falling back to a CLI check at this stage.

A next improvement could be to discover the socket using podman info --format '{{.Host.RemoteSocket.Path}}' if it's not in one of the paths we expected to find it.

cc @r3v5, reporter of the issue

Hey @russellb ! Sure, I will test your fix, no worries.

@russellb

Copy link
Copy Markdown
Contributor Author

@r3v5 thanks. The output of that podman info command would be helpful too

@elezar

elezar commented Jun 11, 2026

Copy link
Copy Markdown
Member

I have a couple of concerns / questions here.

The first is the one that I've already mentioned. This change checks that podman info works, but does not use the configured socket for actually constructing the driver. I would thus be surprised if this change actually allows the podman driver to be used. Due to the precedence of container engine detection, this also means that this is a breaking change for systems where Podman was running on a non-standard socket, but Docker was also installed and usable. On these systems, the gateway will now try to use the Podman driver and fail.

Then, although this seems to align Podman functionality with Docker, there are subtle differences between the two paths. podman info is a slower (and stronger) contract than running docker --version which only checks CLI existence. Podman always uses the configured socket, whereas Docker includes logic to resolve the actual Docker connection later through the local client.

Although it is a slightly larger change than originally proposed, I think there is some benefit in trying to better align the detection paths for Podman and Docker. Ideally these would return a usable driver config (including, for example socket information) and not just a boolean. This config could then be used directly when instantiating the driver(s) instead of rediscovering the relevant config (as is done in the Docker case).

@russellb

Copy link
Copy Markdown
Contributor Author

Thanks, @elezar. I'm happy to work on the changes you described.

@krishicks

Copy link
Copy Markdown
Collaborator

I made a change to podman auto-detection recently (#1536), to avoid using just the existence of the CLI to determine that podman was available. In that change I made sure to align the auto-detection with the actual client socket choice mechanism.

Podman unfortunately has different behavior on macos depending on how you install it, which I talked about in #1690 (comment)

This PR could supersede #1690 (which is scoped to documentation), but it needs to keep the auto-detection mechanism and what the client uses to make the actual connection be aligned, like @elezar has raised.

@russellb

Copy link
Copy Markdown
Contributor Author

Great feedback, thanks @krishicks. I'll iterate on this.

@r3v5

r3v5 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@r3v5 thanks. The output of that podman info command would be helpful too

Hey @russellb ! I am coming back with results from local testing on my machine.

Tested on macOS (Apple Silicon, M3 Pro RAM 36 GB), Podman 5.7.1 via Homebrew.

Detection fix works — gateway now finds podman (Using compute driver driver=podman). Without this PR, it crashes with:

Error:   × configuration error: no compute driver configured and auto-detection found
  │ no suitable driver; set --drivers or OPENSHELL_DRIVERS to kubernetes,
  │ podman, docker, or vm

I ran RUST_LOG=info ./target/release/openshell-gateway --disable-tls

Gateway output with the fix:

 2026-06-12T10:06:18.394079Z  WARN openshell_server::cli: TLS disabled — listening on plaintext HTTP
2026-06-12T10:06:18.394194Z  WARN openshell_server::cli: Neither mTLS user auth nor OIDC nor sandbox JWT auth is configured — the gateway has no authentication mechanism
2026-06-12T10:06:18.394200Z  INFO openshell_server::cli: Starting OpenShell server bind=127.0.0.1:17670
2026-06-12T10:06:18.690885Z  INFO openshell_server: Using compute driver driver=podman
2026-06-12T10:06:18.691059Z  WARN openshell_driver_podman::driver: Podman socket not found; is podman machine running? Try `podman machine start` or set OPENSHELL_PODMAN_SOCKET to override. path=/Users/ianmiller/.local/share/containers/podman/machine/podman.sock
2026-06-12T10:06:18.691323Z  WARN openshell_driver_podman::driver: Podman socket not ready, retrying attempt=1 max_retries=5 error=connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory (os error 2)
2026-06-12T10:06:20.693409Z  WARN openshell_driver_podman::driver: Podman socket not ready, retrying attempt=2 max_retries=5 error=connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory (os error 2)
2026-06-12T10:06:22.695718Z  WARN openshell_driver_podman::driver: Podman socket not ready, retrying attempt=3 max_retries=5 error=connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory (os error 2)
2026-06-12T10:06:24.697982Z  WARN openshell_driver_podman::driver: Podman socket not ready, retrying attempt=4 max_retries=5 error=connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory (os error 2)
2026-06-12T10:06:26.700892Z  WARN openshell_driver_podman::driver: Podman socket not ready, retrying attempt=5 max_retries=5 error=connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory (os error 2)
Error:   × execution error: failed to create compute runtime: connection error: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or
  │ directory (os error 2)

Socket mismatch — after detection, driver construction fails because default_socket_path() returns ~/.local/share/containers/podman/machine/podman.sock which doesn't exist on my system. The actual host-side socket is at:

$ podman machine inspect | grep -A1 PodmanSocket
 "PodmanSocket": {
     "Path": "/var/folders/1q/jx7s14b928n8zvstgfk98lj00000gn/T/podman/podman-machine-default-api.sock"

podman info output

Client:
  APIVersion: 5.7.1
  BuildOrigin: brew
  Built: 1765311063
  BuiltTime: Tue Dec  9 20:11:03 2025
  GitCommit: ""
  GoVersion: go1.25.5
  Os: darwin
  OsArch: darwin/arm64
  Version: 5.7.1
host:
  arch: arm64
  buildahVersion: 1.42.2
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.13-2.fc43.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: '
  cpuUtilization:
    idlePercent: 98.71
    systemPercent: 0.48
    userPercent: 0.81
  cpus: 6
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: coreos
    version: "43"
  emulatedArchitectures:
  - linux/386
  - linux/amd64
  - linux/arm64be
  eventLogger: journald
  freeLocks: 2038
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
    uidmap:
    - container_id: 0
      host_id: 501
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
  kernel: 6.17.7-300.fc43.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 6541344768
  memTotal: 16718606336
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.17.0-1.fc43.aarch64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.17.0
    package: netavark-1.17.1-1.fc43.aarch64
    path: /usr/libexec/podman/netavark
    version: netavark 1.17.1
  ociRuntime:
    name: crun
    package: crun-1.24-1.fc43.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.24
      commit: 54693209039e5e04cbe3c8b1cd5fe2301219f0a1
      rundir: /run/user/501/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/sbin/pasta
    package: passt-0^20250919.g623dbf6-1.fc43.aarch64
    version: |
      pasta 0^20250919.g623dbf6-1.fc43.aarch64-pasta
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: unix:///run/user/501/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/sbin/slirp4netns
    package: slirp4netns-1.3.1-3.fc43.aarch64
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.9.1
      SLIRP_CONFIG_VERSION_MAX: 6
      libseccomp: 2.6.0
  swapFree: 0
  swapTotal: 0
  uptime: 28h 24m 39.00s (Approximately 1.17 days)
  variant: v8
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /var/home/core/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 0
    stopped: 2
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/home/core/.local/share/containers/storage
  graphRootAllocated: 106769133568
  graphRootUsed: 68464410624
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 523
  runRoot: /run/user/501/containers
  transientStore: false
  volumePath: /var/home/core/.local/share/containers/storage/volumes
version:
  APIVersion: 5.7.1
  BuildOrigin: 'Copr: packit/containers-podman-27732'
  Built: 1765238400
  BuiltTime: Tue Dec  9 00:00:00 2025
  GitCommit: f845d14e941889ba4c071f35233d09b29d363c75
  GoVersion: go1.25.4 X:nodwarf5
  Os: linux
  OsArch: linux/arm64
  Version: 5.7.1

@russellb

Copy link
Copy Markdown
Contributor Author

Perfect, thanks. This confirms the non-standard socket location and that discovery needs to include determining socket location to use.

@russellb

Copy link
Copy Markdown
Contributor Author

@r3v5 I've pushed follow-up commits that address the socket mismatch you confirmed. Changes:

  • Socket discovery during detection: When the well-known socket paths don't respond, we now query podman info --format json and check serviceIsRemote. If true (macOS), we run podman machine inspect to get the host-side forwarded socket. If false (native Linux), we use remoteSocket.path directly.
  • Detection and driver always agree on the socket: The discovered path is threaded into PodmanComputeConfig, so the driver connects to the exact socket that detection verified. This applies whether the socket was found via the probe or CLI discovery.
  • DetectedDriver is now an enum: Each driver variant carries its own connection metadata (Podman { socket_path }) rather than a generic optional field.

Precedence for the socket path is: OPENSHELL_PODMAN_SOCKET env var > config file > discovered socket.

Could you re-test on your Homebrew Podman setup? The retry loop against the missing ~/.local/share/containers/podman/machine/podman.sock should be gone — it should now find your socket at /var/folders/.../podman-machine-default-api.sock.

Comment thread crates/openshell-server/src/lib.rs Outdated
Comment thread crates/openshell-server/src/lib.rs Outdated
Comment on lines +859 to +861
Some(driver) => Ok(driver),
Some(detected) => Ok(detected),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here regarding the rename.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread crates/openshell-server/src/lib.rs Outdated
@r3v5

r3v5 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@r3v5 I've pushed follow-up commits that address the socket mismatch you confirmed. Changes:

  • Socket discovery during detection: When the well-known socket paths don't respond, we now query podman info --format json and check serviceIsRemote. If true (macOS), we run podman machine inspect to get the host-side forwarded socket. If false (native Linux), we use remoteSocket.path directly.
  • Detection and driver always agree on the socket: The discovered path is threaded into PodmanComputeConfig, so the driver connects to the exact socket that detection verified. This applies whether the socket was found via the probe or CLI discovery.
  • DetectedDriver is now an enum: Each driver variant carries its own connection metadata (Podman { socket_path }) rather than a generic optional field.

Precedence for the socket path is: OPENSHELL_PODMAN_SOCKET env var > config file > discovered socket.

Could you re-test on your Homebrew Podman setup? The retry loop against the missing ~/.local/share/containers/podman/machine/podman.sock should be gone — it should now find your socket at /var/folders/.../podman-machine-default-api.sock.

Hey @russellb ! Your fix is working, thanks!

1. No socket at the hardcoded path (confirms the bug)

Input:
ls ~/.local/share/containers/podman/machine/podman.sock

Output:
ls: /Users/ianmiller/.local/share/containers/podman/machine/podman.sock: No such file or directory

2. Real socket discovered via podman machine inspect (confirms discovery works)

Input:
podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}'

Output:
/var/folders/1q/jx7s14b928n8zvstgfk98lj00000gn/T/podman/podman-machine-default-api.sock

3. Gateway starts successfully with auto-detected Podman driver (fix complete)

Input:
RUST_LOG=info ./target/release/openshell-gateway --disable-tls

Output:

2026-06-16T10:24:51.486732Z  WARN openshell_server::cli: TLS disabled — listening on plaintext HTTP
2026-06-16T10:24:51.486799Z  WARN openshell_server::cli: Neither mTLS user auth nor OIDC nor sandbox JWT auth is configured — the gateway has no authentication mechanism
2026-06-16T10:24:51.486802Z  INFO openshell_server::cli: Starting OpenShell server bind=127.0.0.1:17670
2026-06-16T10:24:51.663983Z  INFO openshell_server: Using compute driver driver=podman
2026-06-16T10:24:51.711383Z  INFO openshell_driver_podman::driver: Connected to Podman cgroup_version=v2 network_backend=netavark rootless=true
2026-06-16T10:24:51.715036Z  INFO openshell_driver_podman::driver: Bridge network ready network=openshell gateway_ip=Some("10.89.1.1")
2026-06-16T10:24:51.715092Z  INFO openshell_driver_podman::driver: Auto-detected gRPC endpoint grpc_endpoint=http://host.containers.internal:17670 tls=false
2026-06-16T10:24:51.715335Z  INFO openshell_server::provider_refresh: provider credential refresh worker started interval_seconds=60
2026-06-16T10:24:51.715401Z  INFO openshell_server: Server listening address=127.0.0.1:17670
2026-06-16T10:24:51.715408Z  INFO openshell_server: Health server disabled
2026-06-16T10:24:51.715409Z  INFO openshell_server: Metrics server disabled
2026-06-16T10:24:51.715411Z  INFO openshell_server: TLS disabled — accepting plaintext connections

Comment thread crates/openshell-core/src/config.rs Outdated
Comment thread crates/openshell-core/src/config.rs Outdated
Comment thread crates/openshell-core/src/config.rs Outdated
Comment thread crates/openshell-core/src/config.rs Outdated
@russellb
russellb force-pushed the fix/podman-autodetect-cli-fallback branch from d9a1022 to 25e6db7 Compare June 23, 2026 19:24
@russellb
russellb requested a review from maxamillion as a code owner June 23, 2026 19:24
Comment thread crates/openshell-server/src/lib.rs Outdated
@github-actions

Copy link
Copy Markdown

This pull request has had no activity for 14 days and is now marked stale. It may be closed in 7 days if there is no further activity.

@github-actions github-actions Bot added the state:stale Inactive item at risk of automatic closure. label Jul 13, 2026
@TaylorMutch

Copy link
Copy Markdown
Collaborator

@russellb @maxamillion Any updates or discussion needed further on this PR?

@maxamillion

Copy link
Copy Markdown
Collaborator

I was waiting for hear back from @russellb on this one. I thought maybe he was on PTO or something 🙂

@russellb

Copy link
Copy Markdown
Contributor Author

Sorry, just missed the notification. I'm responding and rebasing now.

@russellb
russellb force-pushed the fix/podman-autodetect-cli-fallback branch from ecb5e4f to 2a24776 Compare July 13, 2026 19:32
@russellb

Copy link
Copy Markdown
Contributor Author

I'm letting my agents fight over this for a bit. I'll comment again when it's ready for review.

@TaylorMutch

Copy link
Copy Markdown
Collaborator

Sounds good @russellb - thanks for picking this one back up!

@russellb
russellb force-pushed the fix/podman-autodetect-cli-fallback branch from e5b3f19 to 8329698 Compare July 13, 2026 20:13
@russellb

Copy link
Copy Markdown
Contributor Author

Sounds good @russellb - thanks for picking this one back up!

I think it's OK now.

@krishicks

Copy link
Copy Markdown
Collaborator

#2327 addresses some of the concerns above, including removing the default. I had suggested in #2327 that falling back to asking the podman binary would be a nice addition, forgetting about this PR. Let's get #2327 merged and then rebase this on top.

@krishicks krishicks self-assigned this Jul 20, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

@krishicks and @russellb do we still want to get this in?

@russellb

Copy link
Copy Markdown
Contributor Author

@krishicks and @russellb do we still want to get this in?

I can look at the rebase next week.

@russellb
russellb force-pushed the fix/podman-autodetect-cli-fallback branch from 8329698 to 54179ac Compare August 18, 2026 14:29
@russellb
russellb requested a review from sjenning as a code owner August 18, 2026 14:29
Auto-detection only checked well-known Podman socket paths, so a Podman
machine exposing its API socket at a non-standard location went
undetected. The symlink at a well-known path is not always present; it
varies by Podman version, machine provider, and platform.

Extend detect_podman_socket() to fall back to podman CLI discovery when
no well-known candidate responds: podman info --format json determines
whether the service is local or remote, and podman machine inspect
resolves the host-side forwarded socket for VM-backed machines. All
existing callers (driver auto-detection, the Podman driver, and the VM
driver's container-engine fallback) pick this up without change.

Select the machine backing the active Podman connection instead of the
first entry from podman machine inspect, honoring podman's connection
precedence: CONTAINER_CONNECTION, then CONTAINER_HOST (mapped to a
connection by URI), then the containers.conf default. An explicit
endpoint that maps to no known machine is left unresolved rather than
guessing an unrelated machine. When CONTAINER_HOST is an explicit unix://
socket, use that path directly since podman info connects through it.

Update the gateway config reference and the Podman driver README, which
described probe-only detection.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
@russellb
russellb force-pushed the fix/podman-autodetect-cli-fallback branch from 54179ac to dfc8150 Compare August 18, 2026 15:14
@russellb

Copy link
Copy Markdown
Contributor Author

@krishicks @johntmyers ready for another look

@johntmyers johntmyers closed this Aug 23, 2026
@russellb

Copy link
Copy Markdown
Contributor Author

@johntmyers did you close this on purpose? I think it was still relevant.

@johntmyers

Copy link
Copy Markdown
Collaborator

Oops, no, got caught up in a stale batch!

@johntmyers johntmyers reopened this Aug 23, 2026
@russellb

Copy link
Copy Markdown
Contributor Author

no worries!

@johntmyers

Copy link
Copy Markdown
Collaborator

That being said I'll start a review agent on it if you're ready to finalize

@russellb

Copy link
Copy Markdown
Contributor Author

That being said I'll start a review agent on it if you're ready to finalize

yeah, go for it

@johntmyers johntmyers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

PR Review Status

Thanks @russellb—I checked the rebased implementation against the current callers, the linked macOS failure, the updated docs, and the connection-selection behavior. The fallback is project-valid, but two reachable startup defects need correction before pipeline handoff.

Action required: Please address both blocking findings and push an updated head for a focused follow-up review.

Blocking findings:

  • GATOR-dfc81508-01: Remote discovery can select a different Podman machine than the successful podman info connection.
  • GATOR-dfc81508-02: Newly added Podman CLI probes can block gateway startup indefinitely.

Carried findings:

  • None
Gator metadata
  • Validation: Project-valid localized fix for linked bug #1834; issue #1690 is complementary documentation work, and merged #2327 enabled the current narrower implementation.
  • Docs: Existing Fern gateway reference and Podman README are updated; navigation is unchanged and not needed.
  • Checks: DCO and vouch are green; current-head Branch Checks and Helm Lint are pending.
  • E2E: test:e2e is required for compute-driver runtime discovery, but dispatch is deferred until blocking review feedback is resolved.
  • Head SHA: dfc81508c752486b4aaff9e8a711369f20df02e9
  • Base SHA: 2f7fb65591ee5746217ace154afc0aa6bf1afc6d
  • Merge base SHA: dc374e88784a7e4a7366abd1fdb56c969efe6769
  • Patch ID: ff9f348ed171dc22e39bd07229f3ca1d3538aa56
  • Gator payload: 7
  • Review mode: initial
  • Previous reviewed SHA: none
  • Review budget exhausted: no
  • Maintainer decision required: no
  • Next state: gator:in-review

/// one — otherwise a host with multiple machines could be pointed at the wrong
/// machine's socket.
fn discover_podman_machine_socket() -> Option<PathBuf> {
let output = Command::new("podman")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

Warning — GATOR-dfc81508-01 · Inspect the machine Podman actually selected

Summary: An operator with several Podman machines can make a non-podman-machine-default machine the default connection. podman info then reaches that machine, but no-argument podman machine inspect inspects only podman-machine-default; the later fallback accepts that first result. The gateway can therefore start against the wrong backend and create, inspect, or remove resources there.

Fix: Resolve the active machine first, pass its machine name to podman machine inspect (handling the generated -root suffix), and return None when a named default cannot be mapped instead of substituting another machine. Add an invocation-level regression test.

Verify: Shim podman info as remote, make connection work the default, and emulate no-argument inspect returning only podman-machine-default; discovery must never return that socket and must inspect work explicitly.

Agent context
  • Location: crates/openshell-core/src/config.rs:333
  • Ownership: This PR changes bounded detection failure into a successful connection to a potentially different machine.

/// 4. If `serviceIsRemote` is false, use `remoteSocket.path` directly
/// (on native Linux this IS the real local socket).
fn discover_podman_socket() -> Option<PathBuf> {
let output = Command::new("podman")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gator-agent

Warning — GATOR-dfc81508-02 · Bound Podman discovery subprocesses

Summary: During automatic driver selection, a stalled Podman machine, SSH connection, provider, or helper can keep podman info from exiting. This synchronous Command::output() has no deadline, and the same pattern is used for machine inspection and connection listing. Gateway startup then hangs indefinitely instead of trying Docker or returning an actionable configuration error.

Fix: Route all three discovery commands through one bounded helper with a documented startup-probe deadline. On expiry, kill and reap the child and return None so normal detection can continue or fail. Add a deterministic timeout-path test.

Verify: Put a blocking podman shim on PATH, invoke discovery with no responsive candidate sockets, and confirm it returns within the probe deadline, terminates the child, and permits the next detection outcome.

Agent context
  • Location: crates/openshell-core/src/config.rs:249
  • Sibling sites: The new commands at lines 333 and 379 have the same unbounded wait.

@johntmyers johntmyers added the gator:in-review Gator is reviewing or awaiting PR review feedback label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback state:stale Inactive item at risk of automatic closure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Gateway auto-detection fails to discover Podman on macOS

8 participants