Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5fbfd7

Browse files
authored
fix: fix hang in teardown of TestConn_CoordinatorRollingRestart (#15624)
fixes a flake seen on main:https://github.com/coder/coder/actions/runs/11967210463/job/33364072261the TCP echo server had a waitgroup to ensure that all accepted connections get torn down, but no explicit teardown of the connection. We depended on the tailnet agent closing its side of the connection, which depends on closing the tunneled connection. The tunneled `FIN` could race with tearing down the tunnel itself.So, this PR adds explicit `t.Cleanup` to close the echo connection. It also removes the waitgroup. The purpose of the waitgroup was to ensure that all goroutines created by the echo listener get shut down, but we have `goleak` for that, which fails much faster than the 20 minutes this test run took.
1 parent103824f commitb5fbfd7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

‎enterprise/coderd/coderd_test.go‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,30 +852,26 @@ func TestConn_CoordinatorRollingRestart(t *testing.T) {
852852
}
853853

854854
functcpEchoServer(t*testing.T)string {
855-
varlistenerWg sync.WaitGroup
856855
tcpListener,err:=net.Listen("tcp","127.0.0.1:0")
857856
require.NoError(t,err)
858857
t.Cleanup(func() {
859858
_=tcpListener.Close()
860-
listenerWg.Wait()
861859
})
862-
listenerWg.Add(1)
863860
gofunc() {
864-
deferlistenerWg.Done()
865861
for {
866862
conn,err:=tcpListener.Accept()
867863
iferr!=nil {
868864
return
869865
}
870-
listenerWg.Add(1)
866+
t.Cleanup(func() {
867+
_=conn.Close()
868+
})
871869
gofunc() {
872-
deferlistenerWg.Done()
873870
deferconn.Close()
874871
_,_=io.Copy(conn,conn)
875872
}()
876873
}
877874
}()
878-
879875
returntcpListener.Addr().String()
880876
}
881877

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp