mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-02 22:52:33 -08:00
TestPortlistBackendChurn closed a fixture listener and then required the total number of listening ports in the network namespace to drop. That count covers every process sharing the namespace, so any other test package (testwrapper runs packages in parallel on CI) opening a socket between the two polls kept the count flat or raised it. The CI failures (before=12 after=12, before=11 after=11) were all on GitHub-hosted Linux runners, where only about a dozen sockets exist and any concurrent listener hides the removal. Checking the closed port number instead is not enough. Listings are deduplicated by proto and port, and tcp4 and tcp6 both report as "tcp", so another live socket with the same port number (an [::1] listener in this process, the first iteration's fixture, or another process) still shows up. Instrumenting a port-number check under flakestress recorded 30 such collisions in 11151 runs, each owned by another live socket and never by the closed listener. The backends themselves are fine: Close on a Go listener returns only after close(2), and the kernel unhashes a listening socket synchronously. So make the test fstat the listener to get its inode and check that the backend's li.known entry for that inode is present before the close and gone after it. flakestress -p 4 (concurrent copies share the netns): before: 5261 failures / 7066 runs (3m) port-number check: 5 failures / 9137 runs (8m) after (inode): 0 failures / 11151 runs (9m) Fixes #22348 Change-Id: Ie6699206b1de30d660ebb0092c1f5b421c23dc2c Signed-off-by: Brad Fitzpatrick <[email protected]>