@@ -18,15 +18,16 @@ package oidc
18
18
19
19
import (
20
20
"context"
21
+ "errors"
21
22
"io"
22
23
"net"
23
24
"net/http"
24
- "strings"
25
25
"sync"
26
26
"sync/atomic"
27
27
"testing"
28
28
"time"
29
29
30
+ utilnet "k8s.io/apimachinery/pkg/util/net"
30
31
"k8s.io/apimachinery/pkg/util/wait"
31
32
)
32
33
@@ -86,15 +87,15 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
86
87
87
88
go func () {
88
89
_ , err := io .Copy (backendConn , requestHijackedConn )
89
- if err != nil && ! strings . Contains (err . Error (), "use of closed network connection" ) {
90
+ if err != nil && ! utilnet . IsProbableEOF (err ) {
90
91
t .Errorf ("unexpected writer error: %v" , err )
91
92
}
92
93
close (writerComplete )
93
94
}()
94
95
95
96
go func () {
96
97
_ , err := io .Copy (requestHijackedConn , backendConn )
97
- if err != nil && ! strings . Contains (err . Error (), "use of closed network connection" ) {
98
+ if err != nil && ! utilnet . IsProbableEOF (err ) {
98
99
t .Errorf ("unexpected reader error: %v" , err )
99
100
}
100
101
close (readerComplete )
@@ -116,7 +117,9 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
116
117
}
117
118
118
119
err := server .Shutdown (context .Background ())
119
- t .Logf ("shutdown exit error: %v" , err )
120
+ if err != nil && ! utilnet .IsProbableEOF (err ) {
121
+ t .Logf ("shutdown exit error: %v" , err )
122
+ }
120
123
})
121
124
122
125
var once sync.Once
@@ -147,5 +150,7 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
147
150
}()
148
151
149
152
err = server .Serve (l )
150
- t .Logf ("egress exit error: %v" , err )
153
+ if err != nil && ! errors .Is (err , http .ErrServerClosed ) {
154
+ t .Logf ("egress exit error: %v" , err )
155
+ }
151
156
}
0 commit comments