Repository navigation
ci: isolate container test networks - #35417
willcl-ark wants to merge 2 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
Implements one apprach from #35416 (comment) 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. |
|
Concept ACK - thanks for following up here. |
maflcko
left a comment
There was a problem hiding this comment.
lgtm, seems fine. Left some nits
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.
Previously the (single, shared) networks were left in docker after runs, but with a network container this may get messy. Remove the IPv4 and IPv6 networks when the run is successful. On a failed run, networks will remain dangling and need manual pruning (same behaviour as previously). We can't remove networks automagically form failed runs without first killing the container (docker doesn't let you remove networks which are active), which we want to avoid so we can jump in to failures.
d23a74a to
3fefa9c
Compare
|
CI failure: |
|
Converted to draft, due to failing CI |
|
|
||
|
|
||
| def get_container_network_config(container_name): | ||
| host_id = int.from_bytes(hashlib.sha256(container_name.encode()).digest()[:4], "big") % ((1 << 20) - 1) + 1 |
There was a problem hiding this comment.
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?
| run(["docker", "network", "create", "--ipv6", "--subnet", "1111:1111::/112", "ci-ip6net"], check=False) | ||
| run(["docker", "network", "create", "--subnet", "1.1.1.0/24", "ci-ip4net"], check=False) | ||
| network_name = f"{os.environ['CONTAINER_NAME']}-net" | ||
| run(["docker", "network", "create", "--ipv6", "--subnet", str(ip4_subnet), "--subnet", str(ip6_subnet), network_name], check=False) |
There was a problem hiding this comment.
the check=False now makes me a bit uneasy. Should be safer to remove and check?
| # ifconfig INTERFACE_NAME 1.1.1.5 -alias && ifconfig INTERFACE_NAME inet6 1111:1111::5 -alias # to remove it, after the test | ||
| ADDR1 = '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). | ||
| ADDR2 = '1111:1111::5' | ||
| 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). |
There was a problem hiding this comment.
comment can be removed and the skip msg below needs an update?
| @@ -156,7 +178,7 @@ def main(): | |||
| text=True, | |||
| ).stdout.strip() | |||
|
|
|||
| run(["docker", "network", "connect", "--ip=1.1.1.5", "ci-ip4net", container_id]) # The IP address is used by some of the tests, don't change it just here (keep them in sync). | |||
| run(["docker", "network", "connect", f"--ip={os.environ['BIND_TEST_ROUTABLE_IPV4']}", f"--ip6={os.environ['BIND_TEST_ROUTABLE_IPV6']}", network_name, container_id]) | |||
There was a problem hiding this comment.
the network=none fails ci, so probably needs the --ip=... and ip6=... passed directly above?
|
Closed in favour of #36436 |

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).