File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
25
25
"net/http/httputil"
26
26
"net/url"
27
27
"os"
28
+ "sync"
28
29
29
30
apiextensionsapiserver "k8s.io/apiextensions-apiserver/pkg/apiserver"
30
31
"k8s.io/apimachinery/pkg/runtime"
@@ -207,7 +208,16 @@ func NewConfig(ctx context.Context, opts kcpserveroptions.CompletedOptions) (*Co
207
208
208
209
// break connections on the tcp layer. Setting the client timeout would
209
210
// also apply to watches, which we don't want.
210
- c .GenericConfig .LoopbackClientConfig .Wrap (network .DefaultTransportWrapper )
211
+ // To prevent data races when wrapping the default transport in
212
+ // multiple goroutines the wrapping is done in a once.
213
+ var wrapDefaultTransportWrapper = sync.Once {}
214
+ c .GenericConfig .LoopbackClientConfig .Wrap (func (rt http.RoundTripper ) http.RoundTripper {
215
+ wrapDefaultTransportWrapper .Do (func () {
216
+ rt = network .DefaultTransportWrapper (rt )
217
+ })
218
+ return rt
219
+ })
220
+
211
221
// Set effective version to the default kube version of the vendored libs.
212
222
c .GenericConfig .EffectiveVersion = utilversion .DefaultKubeEffectiveVersion ()
213
223
You can’t perform that action at this time.
0 commit comments