Files
Johnathan Corgan c6609f06d9 Stop the NAT lab start from outrunning its own interface waits
The cone and symmetric starts failed now and then with
`Invalid "netns" value`, a node log ending "Timed out waiting for IPv4
on eth0" and, often, a router that had exited with an empty log. Both
entrypoints gave the harness 30 s from container start to deliver their
interface, and setup-topology.sh delivered it with ten serial helper
containers, five per pair. Starting a container is normally 0.16 s, but
while another lab starts on the same Docker daemon it stalls for 3 to
15 s at a time (measured in create and start; exec, inspect and logs
stay fast, and the kernel and disk were not the bottleneck). Ten such
starts overran the window, so the move landed on an exited container.

Reproduced before the change, with nothing injected: two NAT labs
started together on one daemon failed in 4 of 4 starts:

    Error: argument "2219471" is wrong: Invalid "netns" value
    LAB START FAILED: start_cone exited non-zero on attempt 1; ...
    fips-nat-cone-b: Timed out waiting for IPv4 on eth0
    fips-nat-router-b: (empty log)

A docker shim that delays each `docker run ... --pid=host` by 8 s also
failed both of two runs the same way. A single idle lab passes either
way.

The change:

- setup-topology.sh runs one helper container per pair (delete, add and
  both moves in one `sh -c`, each step echoed) instead of five, checks
  that both containers are still running before it, and after a failed
  move or configure step names any container that exited, with its exit
  code and last 20 log lines. wait_for_pid stops early once a container
  has exited.
- Both entrypoints wait IFACE_WAIT_SECS (default 120 s) for their
  interface, separate from WAIT_TIMEOUT_SECS (30 s), which still bounds
  the relay and STUN waits. The default is set in the scripts, not the
  compose file, so the change applies unchanged to the other branches.
- The router entrypoint now says which interface it timed out on and
  lists its links, instead of exiting silently under set -e.
- testing/nat/README.md describes the start order and the bound.

The longer wait bounds harness setup, not product behaviour; a stuck
setup still fails, naming the container.

After the change: the two-labs-together start passed 4 of 4, with
router B configured at 31 to 34 s after compose up in the symmetric
lab, past the old 30 s window, so both halves of the change are
needed. The 8 s shim passed twice, and the symmetric scenario alone
passed. Breaking the guard with a 130 s shim delay fails with
"fips-nat-cone-a exited (code 1) before its interface was moved",
followed by its log, "Timed out after 120s waiting for IPv4 on eth0".

There is no committed regression test: reproducing this needs Docker
and a second lab or a delaying shim, so it stays a captured run.
2026-10-15 21:52:38 +00:00
..