fix(podman): tighten compose compatibility #3035
Enjoy a better diff viewing experience by clicking one of these URLs:
<!-- devin-review-comment {"id": "BUG_pr-review-job-844fff306c614cfebcf3a8e92fdffd3e_0001", "file_path": "src/harbor/environments/docker/docker.py", "start_line": 1030, "end_line": 1033, "side": "RIGHT", "based_on_repo_rules": false, "kind": "bug"} -->
🟡 Final readiness interval goes unprobed
When less than one second remains, both readiness waiters call sleep instead of probing. Containers ready during that interval fail startup.
<details>
<summary>Prompt for agents</summary>
Both DockerEnvironment._wait_until_compose_exec_ready and DockerEnvironment._wait_until_egress_sidecar_ready truncate the remaining monotonic time to an integer command timeout. When the remainder falls below one second, they sleep until the deadline and raise without checking readiness again. Preserve the elapsed deadline while allowing a final probe during that fractional interval, and cover both waiters with a test where readiness arrives during the last subsecond.
</details>
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=3">
<img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=3" alt="Devin Review">
</picture>
</a>
<!-- devin-review-badge-end -->
---
Was this helpful? React with 👍 or 👎 to provide feedback.
[!NOTE]
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 potential issue.
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=3">
<img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=3" alt="Devin Review">
</picture>
</a>
<!-- devin-review-badge-end -->
✅ Resolved: Both readiness waiters now pass the fractional remaining deadline to the final probe instead of sleeping without probing.
1. PR did not worked for me out of box
Had to create ~/.config/containers/containers.conf
[engine]
compose_providers = ["podman-compose"]
Have podman version 4.9.3 and podman-compose version: 1.0.6
Do have docker/docker compose but at least docker requires sudo.
2.
❯ harbor run --dataset harbor/hello-world --agent pi --env podman
1/1 Mean: 0.000 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0:00:16 0:00:00
harbor/hello-world • pi
┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┓
┃ Trials ┃ Exceptions ┃ Mean ┃
┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━┩
│ 0 │ 1 │ 0.000 │
└────────┴────────────┴───────┘
┏━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Exception ┃ Count ┃
┡━━━━━━━━━━━━━━╇━━━━━━━┩
│ RuntimeError │ 1 │
└──────────────┴───────┘
Job Info
Total runtime: 16s
Results written to jobs/2026-09-11__09-21-31/result.json
Inspect results by running `harbor view jobs`
Share results by running `harbor upload jobs/2026-09-11__09-21-31`
Exception:
❯ cat jobs/2026-09-11__09-21-31/hello-world__LRYybng/exception.txt
Traceback (most recent call last):
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/agents/installed/base.py", line 954, in setup
await self.install(environment)
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/agents/installed/pi.py", line 83, in install
await self.ensure_system_dependencies(environment, ("curl",))
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/agents/installed/base.py", line 662, in ensure_system_dependencies
dict.fromkeys(
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/agents/installed/base.py", line 663, in <genexpr>
package for spec in specs for package in spec.packages[manager]
~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'podman-compose version: 1.0.6\n[\'podman\', \'--version\', \'\']\nusing podman version: 4.9.3\n ** merged:\n {\n "services": {\n "main": {\n "cpus": 1.0,\n "mem_limit": "2048m",\n "build": {\n "context": "/home/egorse-tel/.cache/harbor/tasks/packages/hello-world/hello-world/38d7a077f07fbee8efc78db5dec9a72f82e727510ad1dcfeac0b55fa845256b7/environment"\n },\n "pull_policy": "build",\n "command": [\n "sh",\n "-c",\n "sleep infinity"\n ],\n "environment": {},\n "volumes": [\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/verifier",\n "target": "/logs/verifier"\n },\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/agent",\n "target": "/logs/agent"\n },\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/artifacts/logs/artifacts",\n "target": "/logs/artifacts"\n }\n ]\n }\n },\n "_dirname": "/tmp/tmpjv7y9y1h"\n}\npodman exec --interactive --user root --tty hello-world__lryybng__env_main_1 bash -c for manager in apt-get dnf yum apk; do if command -v "$manager" >/dev/null 2>&1; then printf "%s" "$manager"; break; fi; done\napt-getexit code: 0'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/trial/trial.py", line 406, in run
await self._prepare()
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/trial/trial.py", line 450, in _prepare
await self._setup_agent()
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/trial/trial.py", line 1455, in _setup_agent
await asyncio.wait_for(
File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
File "/home/egorse-tel/.local/share/uv/tools/harbor/lib/python3.12/site-packages/harbor/agents/installed/base.py", line 958, in setup
raise RuntimeError(f"Agent install failed: {exc}") from exc
RuntimeError: Agent install failed: 'podman-compose version: 1.0.6\n[\'podman\', \'--version\', \'\']\nusing podman version: 4.9.3\n ** merged:\n {\n "services": {\n "main": {\n "cpus": 1.0,\n "mem_limit": "2048m",\n "build": {\n "context": "/home/egorse-tel/.cache/harbor/tasks/packages/hello-world/hello-world/38d7a077f07fbee8efc78db5dec9a72f82e727510ad1dcfeac0b55fa845256b7/environment"\n },\n "pull_policy": "build",\n "command": [\n "sh",\n "-c",\n "sleep infinity"\n ],\n "environment": {},\n "volumes": [\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/verifier",\n "target": "/logs/verifier"\n },\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/agent",\n "target": "/logs/agent"\n },\n {\n "type": "bind",\n "source": "/home/egorse-tel/projects/ai/harbor/jobs/2026-09-11__09-21-31/hello-world__LRYybng/artifacts/logs/artifacts",\n "target": "/logs/artifacts"\n }\n ]\n }\n },\n "_dirname": "/tmp/tmpjv7y9y1h"\n}\npodman exec --interactive --user root --tty hello-world__lryybng__env_main_1 bash -c for manager in apt-get dnf yum apk; do if command -v "$manager" >/dev/null 2>&1; then printf "%s" "$manager"; break; fi; done\napt-getexit code: 0'
<!-- mintlify-fork-preview-approval -->
Preview approval required
This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 4d1485d.
<!-- devin-review-comment {"id": "BUG_pr-review-job-2c44387009734db59336ede25aa20f37_0001", "file_path": "src/harbor/environments/docker/docker_unix.py", "start_line": 241, "end_line": 246, "side": "RIGHT", "based_on_repo_rules": false, "kind": "bug"} -->
🔴 Custom container names block Podman execution
When a task sets container_name, _resolve_service_container rejects its project-labeled container because its name differs from the generated names. Podman 1.x cannot run readiness checks or task commands, and engine-copy downloads also fail.
<details>
<summary>Learn more</summary>
A task's Compose file is merged over Harbor's base service, so it can assign container_name to main or a sidecar Compose paths. The engine query already filters by the correct Compose project label, but the returned name is checked against only two generated names. In the Podman 1.x path, every task command uses engine_exec, including the initial readiness check. This failure also applies to downloads using the engine fallback download_file.
Example: A project trial-a with main: {container_name: my-agent} produces a project-labeled container named my-agent. The lookup rejects it, so startup fails despite the container running.
Recommended fix: Resolve service identity from the Compose service label in addition to the project label, rather than inferring it solely from the container name. Preserve project isolation and handle replicas deterministically.
</details>
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
---
Was this helpful? React with 👍 or 👎 to provide feedback.
[!NOTE]
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 new potential issue.
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
✅ Resolved: Resolved: service-label filtering and fallback candidate selection now allow custom container names to be resolved.
<!-- devin-review-comment {"id": "BUG_pr-review-job-e7e4ff36dd02499ea86cc06f6e08b1ae_0001", "file_path": "src/harbor/environments/docker/docker_unix.py", "start_line": 254, "end_line": 257, "side": "RIGHT", "based_on_repo_rules": false, "kind": "bug"} -->
🟡 Stopped replica blocks scaled service execution
When replica 1 is absent, _resolve_service_container can select a stopped replica listed before a running one. podman ps -a includes both, so service execution fails despite a running replica.
<details>
<summary>Learn more</summary>
The service lookup supplies the container ID to engine_exec and to downloads. podman ps -a includes stopped containers. Exact-name matching does not apply when replica 1 is absent or the service uses custom names, and the fallback does not distinguish running from stopped containers. A stopped candidate listed first can therefore make an available service fail to execute or download.
Example: A service has replicas app_api_2 (running) and app_api_3 (stopped), with app_api_1 removed. If ps -a lists replica 3 first, service_exec("true", service="api") calls podman exec on replica 3 and fails.
Recommended fix: Resolve running containers first, or include running state in the ps output and prefer running candidates before falling back to stopped ones. Preserve the exact-name preference among usable candidates.
</details>
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
---
Was this helpful? React with 👍 or 👎 to provide feedback.
[!NOTE]
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 new potential issue.
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
✅ Resolved: Resolved: the lookup now records running candidates separately and prioritizes them over stopped candidates.
@egorse-tel Thanks for testing this and posting the traceback. Both issues are fixed in f3e96f4f.
1. PR did not worked for me out of box
> Had to create ~/.config/containers/containers.conf
> [engine] > compose_providers = ["podman-compose"] >
> Have podman version 4.9.3 and podman-compose version: 1.0.6
> Do have docker/docker compose but at least docker requires sudo.
resolve_podman_runtime() now runs podman compose ls before selecting the Compose V2 path. When docker needs sudo or the Podman socket is down, that check fails and Harbor falls back to podman-compose --in-pod=false on its own. You can remove the containers.conf override.
2.
> KeyError: 'podman-compose version: 1.0.6\n[\'podman\', \'--version\', \'\']\nusing podman version: 4.9.3\n ** merged:\n ... > podman exec --interactive --user root --tty hello-world__lryybng__env_main_1 bash -c for manager in apt-get dnf yum apk; do if command -v "$manager" >/dev/null 2>&1; then printf "%s" "$manager"; break; fi; done\napt-getexit code: 0' >
podman-compose 1.0.6 dumps its version banner, merged Compose JSON, and exit code: 0 to stdout on every exec and allocates --tty by default. On podman-compose 1.x, Harbor now resolves the container with podman ps and runs podman exec directly without a TTY. Compose exec also passes -T now and keeps stderr on its own pipe instead of merging it into stdout, so Pi._get_system_package_manager() gets "apt-get".
<!-- devin-review-comment {"id": "BUG_pr-review-job-1d77bb84a69849fdacf97759bbe00296_0001", "file_path": "src/harbor/environments/docker/docker_unix.py", "start_line": 297, "end_line": 300, "side": "RIGHT", "based_on_repo_rules": false, "kind": "bug"} -->
🔴 Podman startup misses sandbox containers
With podman-compose 1.x and job-scoped Podman storage, _resolve_service_container searches Harbor’s default store. Compose startup uses the job’s store, so the readiness probe never finds the running container.
<details>
<summary>Learn more</summary>
The job’s environment.env becomes persistent_env in create_environment_from_config. Compose startup gets those variables through the Compose subprocess launcher. Podman honors CONTAINERS_STORAGE_CONF when selecting container storage. The readiness probe calls exec, which now looks for the service with podman ps under Harbor’s original environment before launching podman exec with the Compose environment. The lookup therefore searches the wrong store and the trial fails its readiness check.
Example: A rootless Podman job sets environment.env.CONTAINERS_STORAGE_CONF to an absolute configuration file with a different graphroot. Compose starts main in that store, but Harbor keeps polling its usual store until startup times out.
Recommended fix: Use the same effective Podman environment for service lookup and command execution as for Compose startup. Add a readiness regression test that verifies the job’s storage configuration reaches both podman ps and podman exec.
</details>
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
---
Was this helpful? React with 👍 or 👎 to provide feedback.
Devin Review found 1 new potential issue.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/3035" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
Fixed in 4d1485dbc92a601a918b01f805f3dc92f7f70211.
✅ Resolved: This finding concerned job-scoped Podman storage not reaching service discovery. The current changes add the same environment to both podman ps and podman cp, directly fixing the affected lookup path; readiness is also covered by the added environment propagation on ps and exec.
Wanted to mention I just faced the --no-TTY issue, and I am patching this locally. Passing this PR would help.
iandvt
Description
Ports the remaining Podman fixes from #1432 onto the shared
ContainerRuntimelifecycle from #2872 and #3672. Without these changes,podman-compose1.x corruptsexecoutput with its JSON banner and default TTY, fails fallback whendockerneeds root, rejects--no-TTY, and stretches readiness waits pasttimeout_sec.probe_podman_compose_ls()betweenresolve_podman_runtime()andPodmanEnvironment._check_compose_provider()so Harbor falls back topodman-compose --in-pod=falsewhen Docker requires root orpodman.socketis down.ContainerRuntime.exec_via_engineforpodman-compose1.x soUnixOps.engine_exec()resolves containers by Compose project and service labels (preferring running containers) and runspodman execdirectly.execand_apply_network_policy()to-T, keepsstderron its own pipe (merge_stderr=False), and unwraps a single callback exception from thestderrTaskGroupwithout mutating__context__or turning a callbackTimeoutErrorinto a command timeout.down --rmi localonContainerRuntime.remove_local_images, bounds readiness waiters by monotonic wall time, and adds local Podman setup notes todocs-mintlify/sandboxes/pre-integrated-sandboxes.mdx.Validation
ruff check .,ruff format --check ., scopedty check(src/harbor/environments/docker/,podman.py,options.py), and the 4 touched environment unit suites (249 passed, 2 Windows-only skipped) on021f19a113dba1f924157ee05da11699a7ff0262.tests/unit/environments/test_options.pyandtests/runtime/test_network_policy_matrix_podman.pywere not rerun locally after rebasing ontocf4bd0043f4e3a91847edf1b799343caf74cf182because the local venv lacksharbor-framework-client>=0.3.0; both will run in CI.