WIP: ci: isolate container test networks #35417

Closed
willcl-ark wants to merge 2 commits from container-networks into master AGit
willcl-ark commented 2026-05-29 19:54:06 +00:00 (Migrated from github.com)

Fixes #35416

Local CI jobs currently share Docker networks while requesting fixed
routable addresses. That prevents two jobs from running at the same time
because the second container cannot claim the same static IPs. See
33362.

Name the networks "{container_name}-ipv[4|6]", using a subnet based on
the hash of their name, so each CI job gets a separate network while the
tests continue to see the addresses they expect.

Increment them to 11.x.x.x and 1111:2222:x to avoid hitting (existing) dangling networks on machines.

On successful runs, the networks are cleaned up. On failed runs they will remain (as they are being used by the failing container).

Fixes #35416 Local CI jobs currently share Docker networks while requesting fixed routable addresses. That prevents two jobs from running at the same time because the second container cannot claim the same static IPs. See 33362. Name the networks "{container_name}-ipv[4|6]", using a subnet based on the hash of their name, so each CI job gets a separate network while the tests continue to see the addresses they expect. Increment them to 11.x.x.x and 1111:2222:x to avoid hitting (existing) dangling networks on machines. On successful runs, the networks are cleaned up. On failed runs they will remain (as they are being used by the failing container).
DrahtBot commented 2026-05-29 19:54:14 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK fanquake

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35417 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35417.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35417#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [fanquake](https://github.com/bitcoin/bitcoin/pull/35417#issuecomment-4579403644) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3-->
willcl-ark commented 2026-05-29 19:56:09 +00:00 (Migrated from github.com)

Implements one apprach from https://github.com/bitcoin/bitcoin/issues/35416#issuecomment-4578958907

I tried other ways of generating deterministic networks here (we have prcedent for using 'os.getpid()`), but I think in the end this is probably the most robust idea.

IMO cleaning up the networks is nicer, but I can drop that commit if it's not wanted for some reason unknown to me currently (or i can squash it).

Also open to other solutions here.

Implements one apprach from https://github.com/bitcoin/bitcoin/issues/35416#issuecomment-4578958907 I tried other ways of generating deterministic networks here (we have prcedent for using 'os.getpid()`), but I think in the end this is probably the most robust idea. IMO cleaning up the networks is nicer, but I can drop that commit if it's not wanted for some reason unknown to me currently (or i can squash it). Also open to other solutions here.
fanquake commented 2026-05-29 20:01:11 +00:00 (Migrated from github.com)

Concept ACK - thanks for following up here.

Concept ACK - thanks for following up here.
maflcko (Migrated from github.com) approved these changes 2026-06-02 13:44:21 +00:00
maflcko (Migrated from github.com) left a comment

lgtm, seems fine. Left some nits

lgtm, seems fine. Left some nits
maflcko (Migrated from github.com) commented 2026-06-02 13:35:50 +00:00

Why this hunk? This is verbose and only turns a well-understood python run-time error into a harder-to-debug other runtime error?

Why this hunk? This is verbose and only turns a well-understood python run-time error into a harder-to-debug other runtime error?
maflcko (Migrated from github.com) commented 2026-06-02 13:28:46 +00:00

nit: Would it not be easier to spin up a single network with both subnets?

nit: Would it not be easier to spin up a single network with both subnets?
maflcko (Migrated from github.com) commented 2026-06-02 13:29:25 +00:00

nit: Instead of assigning one ip here, and the other below, why not assign both below?

nit: Instead of assigning one ip here, and the other below, why not assign both below?
maflcko (Migrated from github.com) commented 2026-06-02 13:44:08 +00:00
ADDR1 = os.getenv('BIND_TEST_ROUTABLE_IPV4', '1.1.1.5') # This and the address below are set in the CI environment, don't change it just here (keep them in sync).

Maybe change the prefix, so that it isn't tied to the CI?

```suggestion ADDR1 = os.getenv('BIND_TEST_ROUTABLE_IPV4', '1.1.1.5') # This and the address below are set in the CI environment, don't change it just here (keep them in sync). ``` Maybe change the prefix, so that it isn't tied to the CI?
willcl-ark (Migrated from github.com) reviewed 2026-06-02 19:55:50 +00:00
willcl-ark (Migrated from github.com) commented 2026-06-02 19:55:50 +00:00

neat. done.

neat. done.
willcl-ark (Migrated from github.com) reviewed 2026-06-02 19:56:06 +00:00
willcl-ark (Migrated from github.com) commented 2026-06-02 19:56:06 +00:00

both now assigned together

both now assigned together
willcl-ark (Migrated from github.com) reviewed 2026-06-02 19:56:42 +00:00
willcl-ark (Migrated from github.com) commented 2026-06-02 19:56:42 +00:00

At first I had something in cleanup using it, but I dropped it, so have now dropped this too.

At first I had something in cleanup using it, but I dropped it, so have now dropped this too.
willcl-ark (Migrated from github.com) reviewed 2026-06-02 19:56:49 +00:00
willcl-ark (Migrated from github.com) commented 2026-06-02 19:56:49 +00:00

Done

Done
DrahtBot commented 2026-06-10 15:19:02 +00:00 (Migrated from github.com)

CI failure:

+ docker network create --ipv6 --subnet 11.51.44.16/28 --subnet 1111:2222::3:32c1:0/112 ci_arm_linux-net
cd1c43f84c4b72cb079c930b48765e36ea8e79d751d336e90365917a9f5a72d9
Prune all dangling bitcoin-ci-test images
+ docker image prune --force --filter label=bitcoin-ci-test
Total reclaimed space: 0B
+ docker run --rm --interactive --detach --tty --cap-add=LINUX_IMMUTABLE --mount=type=bind,src=/home/runner/work/bitcoin/bitcoin,dst=/home/runner/work/bitcoin/bitcoin,readonly --mount=type=bind,src=/home/runner/work/_temp/ccache_dir,dst=/home/runner/work/_temp/ccache_dir --mount=type=bind,src=/home/runner/work/_temp/depends/built,dst=/home/runner/work/_temp/depends/built --mount=type=bind,src=/home/runner/work/_temp/depends/sources,dst=/home/runner/work/_temp/depends/sources --mount=type=bind,src=/home/runner/work/_temp/previous_releases,dst=/home/runner/work/_temp/previous_releases --mount=type=bind,src=/home/runner/work/_temp/build,dst=/home/runner/work/_temp/build --env-file=/tmp/env-runner-ci_arm_linux --name=ci_arm_linux --network=none --platform=linux/arm64 ci_arm_linux
+ docker network connect --ip=11.51.44.21 --ip6=1111:2222::3:32c1:5 ci_arm_linux-net b9b658b4df7a1d872d5e588104b7ff98d97f76a0c19fac54310aeef8bd2f23eb
Error response from daemon: container cannot be connected to multiple networks with one of the networks in private (none) mode
Command '['docker', 'network', 'connect', '--ip=11.51.44.21', '--ip6=1111:2222::3:32c1:5', 'ci_arm_linux-net', 'b9b658b4df7a1d872d5e588104b7ff98d97f76a0c19fac54310aeef8bd2f23eb']' returned non-zero exit status 1.
CI failure: ``` + docker network create --ipv6 --subnet 11.51.44.16/28 --subnet 1111:2222::3:32c1:0/112 ci_arm_linux-net cd1c43f84c4b72cb079c930b48765e36ea8e79d751d336e90365917a9f5a72d9 Prune all dangling bitcoin-ci-test images + docker image prune --force --filter label=bitcoin-ci-test Total reclaimed space: 0B + docker run --rm --interactive --detach --tty --cap-add=LINUX_IMMUTABLE --mount=type=bind,src=/home/runner/work/bitcoin/bitcoin,dst=/home/runner/work/bitcoin/bitcoin,readonly --mount=type=bind,src=/home/runner/work/_temp/ccache_dir,dst=/home/runner/work/_temp/ccache_dir --mount=type=bind,src=/home/runner/work/_temp/depends/built,dst=/home/runner/work/_temp/depends/built --mount=type=bind,src=/home/runner/work/_temp/depends/sources,dst=/home/runner/work/_temp/depends/sources --mount=type=bind,src=/home/runner/work/_temp/previous_releases,dst=/home/runner/work/_temp/previous_releases --mount=type=bind,src=/home/runner/work/_temp/build,dst=/home/runner/work/_temp/build --env-file=/tmp/env-runner-ci_arm_linux --name=ci_arm_linux --network=none --platform=linux/arm64 ci_arm_linux + docker network connect --ip=11.51.44.21 --ip6=1111:2222::3:32c1:5 ci_arm_linux-net b9b658b4df7a1d872d5e588104b7ff98d97f76a0c19fac54310aeef8bd2f23eb Error response from daemon: container cannot be connected to multiple networks with one of the networks in private (none) mode Command '['docker', 'network', 'connect', '--ip=11.51.44.21', '--ip6=1111:2222::3:32c1:5', 'ci_arm_linux-net', 'b9b658b4df7a1d872d5e588104b7ff98d97f76a0c19fac54310aeef8bd2f23eb']' returned non-zero exit status 1.
DrahtBot commented 2026-06-19 08:46:49 +00:00 (Migrated from github.com)

Converted to draft, due to failing CI

Converted to draft, due to failing CI
First-time contributor

Base: 66776840beb558f7e84451c2c55457f0e06242f0
Head: 3fefa9c120bcb0636e630e299361a513e0c30c40

🟠 Major

The container cannot join a network after starting with --network=none (ci/test/02_run_container.py:170, head)

The Docker-backed path starts the container with --network=none and then tries to attach network_name. Docker rejects attaching another network to a container in none mode, so run() exits before installation and testing, and the cleanup below is skipped. Start the container directly on network_name with both requested static addresses instead. (github.com)

Review coverage was incomplete. The independent review did not complete. The adversarial_glm review did not complete. Verification was partial.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `66776840beb558f7e84451c2c55457f0e06242f0` Head: `3fefa9c120bcb0636e630e299361a513e0c30c40` ##### 🟠 Major **The container cannot join a network after starting with `--network=none`** (ci/test/02_run_container.py:170, head) The Docker-backed path starts the container with `--network=none` and then tries to attach `network_name`. Docker rejects attaching another network to a container in `none` mode, so `run()` exits before installation and testing, and the cleanup below is skipped. Start the container directly on `network_name` with both requested static addresses instead. ([github.com](https://github.com/moby/moby/issues/21132?utm_source=openai)) Review coverage was incomplete. The independent review did not complete. The adversarial_glm review did not complete. Verification was partial. [Full review report](<https://review.fish.foo/traces/35417-3fefa9c120bcb0636e630e299361a513e0c30c40-365-1.html>)
maflcko (Migrated from github.com) reviewed 2026-10-05 11:39:29 +00:00
maflcko (Migrated from github.com) left a comment

left more feedback, and already addressed all in https://github.com/bitcoin/bitcoin/pull/36435

Also, rewritten the branch by inverting the commit order for easier review.

left more feedback, and already addressed all in https://github.com/bitcoin/bitcoin/pull/36435 Also, rewritten the branch by inverting the commit order for easier review.
maflcko (Migrated from github.com) commented 2026-10-05 11:36:12 +00:00

seems a bit confusing to do all the hashing and the -1, and the +1 "hacks", when a stable int id can just be derived from the container (or rather sorted file name index) name directly. Of course this won't be stable across commits, but we can't really guarantee cross-commit ci concurrent runs anyway?

seems a bit confusing to do all the hashing and the -1, and the +1 "hacks", when a stable int id can just be derived from the container (or rather sorted file name index) name directly. Of course this won't be stable across commits, but we can't really guarantee cross-commit ci concurrent runs anyway?
maflcko (Migrated from github.com) commented 2026-10-05 11:37:33 +00:00

the check=False now makes me a bit uneasy. Should be safer to remove and check?

the check=False now makes me a bit uneasy. Should be safer to remove and check?
maflcko (Migrated from github.com) commented 2026-10-05 11:38:45 +00:00

the network=none fails ci, so probably needs the --ip=... and ip6=... passed directly above?

the network=none fails ci, so probably needs the --ip=... and ip6=... passed directly above?
maflcko (Migrated from github.com) commented 2026-10-05 11:38:04 +00:00

comment can be removed and the skip msg below needs an update?

comment can be removed and the skip msg below needs an update?
willcl-ark commented 2026-10-06 10:16:51 +00:00 (Migrated from github.com)

Closed in favour of #36436

Closed in favour of #36436
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35417
No description provided.