Skip to content

fix(tier3): name Docker address-pool exhaustion and document trial network cleanup - #557

Merged
rng1995 merged 10 commits into
mainfrom
naren/port-tier3-docker-trial-cleanup
Nov 16, 2026
Merged

rng1995 merged 10 commits into
mainfrom
naren/port-tier3-docker-trial-cleanup

Conversation

@rng1995

@rng1995 rng1995 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Each Docker-mode trial's Compose project normally creates its own Docker network, and Docker carves those networks from a small set of default address pools. A skipped or exceeded Ctrl+C wait, a Ctrl+C on Windows, or a killed SkillEvaluator process can leave a trial's containers and its Compose network behind. Once enough networks pile up, every new trial fails with all predefined address pools have been fully subnetted.

On main, two things make this hard to recover from:

  • The documented cleanup lists only running containers and removes them with docker rm -f. It never mentions the Compose networks, which are what use up the pools.
  • The secure Compose error puts the long command line before Docker's stderr, and the trial failure reason is cut at 600 characters. Docker's line falls past the cut, so nothing in the reason names the cause.

This PR names the cause in the trial failure reason and fixes the documented cleanup. It does not add any automatic removal of Docker resources.

Changes

  • collector._exception_details: when Compose fails to create a trial network (failed to create network ...) with Docker's address-pool error (all predefined address pools have been fully subnetted or could not find an available, non-overlapping IPv4 address pool, any case), the reason places a short note right after the exception type. The note names the cause, lists the leftover trial containers and networks (docker ps -a --filter label=com.docker.compose.project and docker network ls --filter label=com.docker.compose.project), asks to check their names, and removes the containers with docker rm -f before the networks with docker network rm, because Docker refuses to remove a network that still has a container attached. It also offers a lower --n-concurrent or --max-agents. The note is 368 characters, so it fits inside the reason's 600-character bound together with the exception type.
  • Agent runtime failures do not get the note. Their messages carry the agent's own stdout and stderr, which can quote Docker's error, for example when the agent reads a log while working on a Docker task. The note is skipped for every type the collector already treats as an agent runtime failure (NonZeroAgentExitCodeError, AgentTimeoutError, ApiRateLimitError and the rest), so their reasons, and the agent runtime classification that reads them, stay as recorded.
  • docs/tier3-live-evaluation.mdx: the leftover-resources note is now its own bullet. It names a skipped or exceeded Ctrl+C wait, a Ctrl+C on Windows, and a SkillEvaluator process killed rather than interrupted (for example with kill or by a cancelled CI job). It lists stopped containers too (docker ps -a --filter label=com.docker.compose.project), lists the Compose networks (docker network ls --filter label=com.docker.compose.project), and removes the containers with docker rm -f before the networks with docker network rm. The advice to check project names before removing anything stays.
  • docs/tier3-live-evaluation.mdx Troubleshooting: a new entry for all predefined address pools have been fully subnetted explains the cause. Each running trial holds a network, so a run holds up to --n-concurrent networks for each agent running in parallel, and up to --max-agents agents run in parallel, every selected agent by default. The entry gives the same scoped recipe, or a lower --n-concurrent or --max-agents. It does not suggest docker network prune, which would also remove other projects' unused networks on a shared host.
  • CHANGELOG.md: one Fixed entry under Unreleased.

Kept from public

  • The exception type stays first in the reason (RuntimeError: <note> <message>). Code that matches reasons on their type prefix, such as AgentTimeoutError: in timeout recovery and AgentSetupNetworkError: in the setup retry check, behaves as before.
  • All other reasons are unchanged, including agent runtime failures whose output quotes Docker's error, and the full redacted exception.txt is still copied into the run output.
  • The manual, check-the-names cleanup stays the documented approach. SkillEvaluator does not remove containers or networks itself. An automatic sweep would run docker rm -f and docker network rm on the user's Docker host, and it still could not help when the SkillEvaluator process is killed, because the Harbor path has no SIGTERM or SIGHUP handling. That stays a separate decision.
  • The runtime preflight detail is unchanged. Its 1,500-character bound already keeps Docker's line for a typical Compose failure.

Tests

  • New tests in tests/test_harbor_collector_runtime_failures.py, 28 cases in 8 tests:
    • test_docker_address_pool_exhaustion_is_named_before_the_reason_cut (3 cases: both Docker messages, plus upper case). Docker's line starts past character 600. The reason starts with the type and the note, names the scoped listing, never mentions prune, and is exactly 600 characters.
    • test_docker_address_pool_note_removes_trial_containers_before_networks: the whole note fits inside the cut, lists both containers and networks with the Compose label filter, asks to check their names, puts docker rm -f before docker network rm, ends with or lower --n-concurrent or --max-agents., and never mentions prune.
    • test_docker_address_pool_note_without_exception_type: a Compose network failure with no exception type also gets the note.
    • test_docker_address_pool_error_outside_compose_network_creation_gets_no_note (2 cases): Docker's phrase quoted in a verifier log, and the phrase ahead of an unrelated failed to create network error, keep their reasons unchanged.
    • test_agent_runtime_failures_get_no_address_pool_note (18 cases, one per agent runtime failure type): a Compose-shaped address-pool message keeps its reason unchanged.
    • test_agent_failure_quoting_docker_address_pool_error_keeps_its_reason: a NonZeroAgentExitCodeError whose stdout has API Error: 401 Unauthorized before a quoted Docker address-pool error. _agent_runtime_failure_reason returns the full recorded reason with the 401 line and no note.
    • test_other_docker_network_failures_get_no_address_pool_note: another network failure keeps its reason unchanged.
    • test_trial_failure_names_docker_address_pool_exhaustion: end to end through collect_harbor_results, the trial failure reason names the cause.
  • Fail-before on main 33b382f (PYTHONPATH pointing at main's src): 6 failed and 22 passed. The 6 failures are the tests that expect the note. The 22 guard tests pass on main as expected, because main adds no note.
  • On this branch: all 28 pass.
  • Targeted modules on this branch (the three collector test modules, test_harbor_timeout_recovery.py, the docs tests that read tier3-live-evaluation.mdx, test_ci_workflows.py, test_oss_packaging.py and test_ci_change_classifier.py): 916 passed, 26 failed. The same 26 tests also fail on main 33b382f in the same local environment, which has Harbor 0.24 installed while the project pins 0.25: 24 fail importing harbor.agents.agent_auth_resolution, 1 compares the environment keyword contract with the installed Harbor source, and 1 is test_validate_tier3_writes_the_same_report_pair. They are not affected by this change.
  • ruff check and ruff format --check on the changed .py files: clean.
  • scripts/check_oss_boundary.py: passed.
  • Merge checks: the branch includes main 8b19b2fe3. Against open PR Enable public plugin assessment and saved-run reports #394, git merge-tree --write-tree conflicts only in the files where Enable public plugin assessment and saved-run reports #394 already conflicts with main; none of them is a file this PR changes apart from CHANGELOG.md.
  • The full suite is run separately.

🤖 Generated with Claude Code

rng1995 and others added 4 commits November 13, 2026 12:23
…tworks

Each trial's Compose project normally creates its own Docker network, and
Docker carves those from a small set of default address pools. When an
interrupted or killed run leaves the networks behind, later trials fail with
"all predefined address pools have been fully subnetted". The secure Compose
error puts the long command line before Docker's stderr, so the 600-character
trial failure reason cut that line off and nothing named the cause.

The trial failure reason now places a short note right after the exception
type when Docker's message reports exhausted address pools. The note names the
cause and points at the scoped listing of Compose networks or a lower
--n-concurrent. The exception type stays first, so reason consumers that match
on the type prefix are unaffected.

The documented cleanup for leftovers now covers a SkillEvaluator process that
is killed rather than interrupted, lists stopped containers too, and lists and
removes the trials' Compose networks after their containers, keeping the
advice to check project names first. A new troubleshooting entry covers the
address-pool error without suggesting a host-wide network prune.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The leftover-resources note now stands in its own bullet, so "a Windows run"
read as if any Windows run left containers behind. Only an interrupted run
does: Ctrl+C on Windows stops the Harbor task tree at once, without the
graceful teardown wait. Name the skipped or exceeded Ctrl+C wait and a Ctrl+C
on Windows directly.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ddress-pool note

Docker refuses to remove a network that still has a container attached.
After a killed run or a Ctrl+C on Windows, a leftover trial container can
still be running on its Compose network, so following the address-pool
note in the trial failure reason (which named only the networks) ended in
an "has active endpoints" error.

The note now lists both the trial containers and the networks with the
scoped Compose label filter, asks to check their names, and removes the
containers with docker rm -f before the networks with docker network rm,
matching the documented recipe. It still fits well inside the 600-character
reason bound and never suggests a host-wide prune.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The change targets a real recovery problem. Docker's address-pool error used to fall past the 600-character reason cut. Now the failure reason names that cause right after the exception type, and the documented cleanup covers the leftover Compose networks, removing containers before networks. The new tests pass and pin the note's placement, content and length. Two small gaps remain. First, the note is added to any exception whose message contains Docker's phrase, including agent-command failures that embed the agent's own output. Second, the concurrency advice names only --n-concurrent, but parallel agents multiply the number of trial networks.

rng1995 and others added 4 commits November 14, 2026 11:12
The note was added to any exception whose message quoted Docker's
address-pool error. Agent exit errors carry the agent's own stdout and
stderr, so an agent that read a log quoting that error and then failed
on, for example, a 401 got a reason that started with host cleanup
advice. The note also pushed the 401 line past the 600-character cut,
so the trial was no longer classed as an agent runtime failure.

Add the note only when the exception type is not an agent runtime
failure type and Docker's error follows Compose's
"failed to create network" prefix.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--n-concurrent limits concurrent trials per agent, and agents run in
parallel up to --max-agents, which defaults to every selected agent.
Several agents at the default --n-concurrent can use up Docker's
address pools without that flag ever being raised, so the note now
offers a lower --n-concurrent or --max-agents. It still fits well
inside the 600-character reason cut.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each running trial holds a network, so a run holds up to --n-concurrent
networks for each agent running in parallel, and up to --max-agents
agents run in parallel. The address-pool Troubleshooting entry now says
so and offers a lower --n-concurrent or --max-agents.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chrisknvidia chrisknvidia 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.

This is worth merging. It is a small fix, not urgent. On main nothing in a trial failure names Docker's address-pool error (the long Compose command comes first and the 600-character cut drops Docker's line), and the documented cleanup lists containers only, even though docker rm -f leaves the Compose network behind. The PR names the cause in the failure reason and extends the cleanup docs to the networks, without removing anything on the user's Docker host.

What I flagged earlier looks fixed. The note is now added only when the exception is not an agent failure type and Docker's error follows Compose's failed to create network, so an agent whose output quotes Docker's phrase keeps its real error: I re-ran my case (a NonZeroAgentExitCodeError with a 401 line before the Docker phrase) and _agent_runtime_failure_reason returns the reason again, with no note. The note and the Troubleshooting entry now name --max-agents next to --n-concurrent and say that each running trial holds a network. When I remove either guard from the new code, the new guard tests fail.

Not verified: I could not run Docker, so I did not see the pool error or the cleanup itself. The PR's own test module imports Harbor, which is too old in my environment, so I ran the 27 collector-only cases it adds in isolation (they pass here, and 5 fail on main); the end-to-end collection test I could not run. CI is green and the branch merges cleanly with main.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrisknvidia

Copy link
Copy Markdown
Collaborator

Review follow-up on 817e8f824e81.

No new source defect confirmed. The earlier agent-output misclassification and max-agents guidance findings are addressed. The full collector/runtime-failure module passed 158 tests with pinned Harbor 0.25.0. I did not deliberately exhaust Docker network pools or delete networks/containers; failure classification and report propagation were checked with result artifacts/tests. Please resolve the current merge conflict and preserve container-before-network cleanup guidance.

Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rng1995
rng1995 merged commit 1244b3c into main Nov 16, 2026
27 checks passed
@rng1995
rng1995 deleted the naren/port-tier3-docker-trial-cleanup branch November 16, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants