From e12c1fed6336048d6ab854bbfab95eccf7c1b372 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 14 Jul 2022 00:23:18 -0400 Subject: [PATCH] 16552: Avoid port collision due to port assignment races in tests. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/boot/nginx.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/boot/nginx.go b/lib/boot/nginx.go index 8a29823a12..b391c4dc8c 100644 --- a/lib/boot/nginx.go +++ b/lib/boot/nginx.go @@ -32,8 +32,19 @@ func (runNginx) Run(ctx context.Context, fail func(error), super *Supervisor) er if err != nil { return err } + extListenHost := "0.0.0.0" + if super.ClusterType == "test" { + // Our dynamic port number assignment strategy (choose + // an available port, write it in a config file, and + // have another process/goroutine bind to it) is prone + // to races when used by concurrent supervisors. In + // test mode we don't accept remote connections, so we + // can avoid collisions by using the per-cluster + // loopback address instead of 0.0.0.0. + extListenHost = super.ListenHost + } vars := map[string]string{ - "LISTENHOST": "0.0.0.0", + "LISTENHOST": extListenHost, "UPSTREAMHOST": super.ListenHost, "SSLCERT": filepath.Join(super.tempdir, "server.crt"), "SSLKEY": filepath.Join(super.tempdir, "server.key"), -- 2.30.2