From 32cbed9658059ffdad881083ba101d5d4089acc4 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 17 Apr 2026 13:47:17 -0700 Subject: [PATCH] fix(fuse-tests): avoid ephemeral port reuse racing weed mini bind freePort allocated in [20000, 55535], which overlaps the Linux ephemeral range (32768-60999). The kernel could reuse the chosen port for an outbound connection between the test closing its listener and weed mini re-checking availability, causing: Port allocation failed: port N for Filer (specified by flag filer.port) is not available on 0.0.0.0 and cannot be used Narrow the range to [20000, 32000] to stay below the ephemeral floor, and pass -ip.bind=127.0.0.1 so mini's pre-check runs on the same IP the test actually reserved the port on. --- test/fuse_integration/framework_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/fuse_integration/framework_test.go b/test/fuse_integration/framework_test.go index e75c83348..b7f61e0aa 100644 --- a/test/fuse_integration/framework_test.go +++ b/test/fuse_integration/framework_test.go @@ -84,11 +84,14 @@ func NewFuseTestFramework(t *testing.T, config *TestConfig) *FuseTestFramework { // freePort asks the OS for a free TCP port in a range where the gRPC // offset (port + 10000) won't collide with well-known ports. +// Stay below the Linux ephemeral floor (32768) so the kernel does not +// reuse the chosen port for an outbound connection between close() here +// and re-bind in the child "weed mini" process. func freePort(t *testing.T) int { t.Helper() const ( minServicePort = 20000 - maxServicePort = 55535 + maxServicePort = 32000 ) portCount := maxServicePort - minServicePort + 1 @@ -247,6 +250,7 @@ func (f *FuseTestFramework) startMini(config *TestConfig) error { "mini", "-dir=" + f.dataDir, "-ip=127.0.0.1", + "-ip.bind=127.0.0.1", "-filer.port=" + strconv.Itoa(f.filerPort), "-s3=false", "-webdav=false",