From 5814269189b40bb08b47df28ca21f7610d755c52 Mon Sep 17 00:00:00 2001 From: Oxygen <1391083091@qq.com> Date: Thu, 11 Jun 2026 23:50:47 +0800 Subject: [PATCH] fix(docker): add Podman-machine gateway regression test Add a macOS-only regression test for Podman machine bridging (#1358). On macOS hosts the bridge gateway IP only exists inside the VM, so binding fails with EADDRNOTAVAIL. The existing host_runtime_requires_host_gateway_alias() gate already handles this, but the regression test ensures Podman-machine-style SystemInfo (fedora, localhost.localdomain, no labels) is routed via HostGateway. Also document host_runtime_requires_host_gateway_alias() to make the macOS constraint discoverable at the call site. Co-developed-by: Akram Ben Aissi Closes #1358 Signed-off-by: Oxygen <1391083091@qq.com> --- crates/openshell-driver-docker/src/lib.rs | 6 +++++ crates/openshell-driver-docker/src/tests.rs | 25 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/crates/openshell-driver-docker/src/lib.rs b/crates/openshell-driver-docker/src/lib.rs index d05772760..2acbb278b 100644 --- a/crates/openshell-driver-docker/src/lib.rs +++ b/crates/openshell-driver-docker/src/lib.rs @@ -2306,6 +2306,12 @@ fn docker_gateway_route_for_host( } } +/// On macOS, Docker-compatible runtimes (Docker Desktop, Colima, Podman +/// machine, etc.) run Linux networking inside a VM. The bridge gateway IP is +/// therefore not assigned on the host interface where the gateway process +/// runs, so binding the gateway listener to that IP fails with +/// EADDRNOTAVAIL. Always route callbacks via host-gateway aliases on macOS +/// hosts, regardless of which runtime is detected. fn host_runtime_requires_host_gateway_alias() -> bool { cfg!(target_os = "macos") } diff --git a/crates/openshell-driver-docker/src/tests.rs b/crates/openshell-driver-docker/src/tests.rs index 8b0921e8a..9657aef97 100644 --- a/crates/openshell-driver-docker/src/tests.rs +++ b/crates/openshell-driver-docker/src/tests.rs @@ -382,6 +382,31 @@ fn docker_gateway_route_uses_bridge_gateway_for_linux_docker() { ); } +// Regression for macOS + OPENSHELL_DRIVERS=docker against a Podman-machine +// socket (OpenShell issue #1358): the daemon looks like generic Linux, but the +// bridge gateway IP only exists inside the VM. Binding it on the host fails +// with EADDRNOTAVAIL during gateway startup. +#[test] +#[cfg(target_os = "macos")] +fn docker_gateway_route_uses_host_gateway_for_podman_machine_on_macos() { + let info = SystemInfo { + // Observed values when docker CLI talks to podman machine API. + operating_system: Some("fedora".to_string()), + name: Some("localhost.localdomain".to_string()), + labels: None, + ..Default::default() + }; + + let route = docker_gateway_route( + &info, + // Typical Podman machine bridge gateway; not routable on the macOS host. + IpAddr::V4(Ipv4Addr::new(10, 89, 0, 1)), + DEFAULT_SERVER_PORT, + None, + ); + assert_eq!(route, DockerGatewayRoute::HostGateway); +} + #[test] fn docker_gateway_route_uses_host_gateway_when_host_runtime_requires_it() { let info = SystemInfo {