kubernetes: integration tests log many "http: TLS handshake error from 127.0.0.1:55336: EOF" errors

What happened?

Ran

go test ./test/integration/apiserver/admissionwebhook -v -run TestWebhookAdmissionWithWatchCache

What did you expect to happen?

tests run without TLS errors

How can we reproduce it (as minimally and precisely as possible)?

Run integration tests

Anything else we need to know?

This happened on go1.17 and go1.18, so it’s not new, but indicates we either have a setup issue in our integration tests, or our logging is outputting errors in situations that should not error

Kubernetes version

$ kubectl version
# paste output here

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 7
  • Comments: 22 (15 by maintainers)

Most upvoted comments

we are seeing this log in our operator which has a built-in webhook for conversion/validating/mutating. It seems doesn’t affect the functionalities of the webhook but it keeps appearing in log like forever. As the log shows no other info as to the source of the log we have no idea where to ask for a fix. The go version is 1.19 and kubernetes version is 1.26.3. I’d be glad to provide more information if required. Thanks!

We also see these errors a lot in cert-manager webhook logs when deployed on Kubernetes 1.23 or 1.24 when a larger number of resources are being applied that get validated by webhook.

We also see some ‘connection reset’ errors that also appear to be new in 1.23 and 1.24, not sure if those might be related:

...
I0606 08:43:29.003459       1 logs.go:59] http: TLS handshake error from 10.244.0.1:23178: EOF
I0606 08:43:29.013764       1 logs.go:59] http: TLS handshake error from 10.244.0.1:8326: read tcp 10.244.0.5:10250->10.244.0.1:8326: read: connection reset by peer
I0606 08:43:29.014414       1 logs.go:59] http: TLS handshake error from 10.244.0.1:14238: EOF
...

/priority important-soon

Webhooks has a very interesting and complex setup, let me write it down for reference:

Webhooks inside the apiserver use a RESTClient to contact the webhooks, this is handled by the ClientManager

https://github.com/kubernetes/kubernetes/blob/dda9bcb082be058c30c83d45e757edbaac8dc65f/staging/src/k8s.io/apiserver/pkg/util/webhook/client.go#L65-L66

conversion and validationg/mutation webhooks doesn’t use the same client manager though

$ grep -r NewClientManager staging/
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/webhook_converter.go:       clientManager, err := webhook.NewClientManager(
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/webhook.go:   cm, err := webhookutil.NewClientManager(
staging/src/k8s.io/apiserver/pkg/util/webhook/client.go:// NewClientManager creates a clientManager.
staging/src/k8s.io/apiserver/pkg/util/webhook/client.go:func NewClientManager(gvs []schema.GroupVersion, addToSchemaFuncs ...func(s *runtime.Scheme) error) (ClientMa

The ClientManager caches the clients, however, the key takes the URL path into account, that means that same host will not be cached if they have different path, i.e. webhook.url/validatingv1 and webhook.url/validatingv1beta1 will have a different client

https://github.com/kubernetes/kubernetes/blob/dda9bcb082be058c30c83d45e757edbaac8dc65f/staging/src/k8s.io/apiserver/pkg/util/webhook/client.go#L122-L124

but, interestingly, the transport is cached ONLY for webhooks using URL, because the transport is cacheable for the Client

https://github.com/kubernetes/kubernetes/blob/0765ba8e54f0c9e5f221e505a24759fa18beaf2e/staging/src/k8s.io/client-go/transport/cache.go#L136

webhooks using a Service use a custom dialer, so the transport is not cached, but (I have to verify it) the client will be cached by the ClientManager cache

https://github.com/kubernetes/kubernetes/blob/dda9bcb082be058c30c83d45e757edbaac8dc65f/staging/src/k8s.io/apiserver/pkg/util/webhook/client.go#L148-L168

Regarding the http: TLS handshake error from 127.0.0.1:56638: EOF errors, I was surprised it wasn’t happening on this test too

https://github.com/kubernetes/kubernetes/blob/0765ba8e54f0c9e5f221e505a24759fa18beaf2e/test/integration/apiserver/admissionwebhook/load_balance_test.go#L51

but if we just remove the sleep on the webhook server

diff --git a/test/integration/apiserver/admissionwebhook/load_balance_test.go b/test/integration/apiserver/admissionwebhook/load_balance_test.go
index 0ed6c3911f3..42369d5c780 100644
--- a/test/integration/apiserver/admissionwebhook/load_balance_test.go
+++ b/test/integration/apiserver/admissionwebhook/load_balance_test.go
@@ -276,7 +276,7 @@ func newLoadBalanceWebhookHandler(recorder *connectionRecorder) http.Handler {
                }
 
                // simulate a loaded backend
-               time.Sleep(2 * time.Second)
+               //time.Sleep(2 * time.Second)
                allow(w)
        })
 }

the test fails with the TLS handshake errors

2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57444: EOF
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57440: EOF
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57442: EOF
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57446: EOF
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57452: EOF
    load_balance_test.go:208: expected no additional connections (reusing kept-alive connections), got 9
E0330 18:27:45.585947  426498 context.go:98] "Attempted to add audit annotations from unsupported request chain" annotations=[authorization.k8s.io/decision allow authorization.k8s.io/reason ]
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57448: EOF
2022/03/30 18:27:45 http: TLS handshake error from 127.0.0.1:57450: EOF

based on that I think that this problem is related to

https://github.com/golang/go/issues/50984

I’ve tried different things without success, I think that the divergence between URL and Service webhooks and the multiple caching layers can be problematic in a future (if it is not a problem already 😃 )