Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetesClient does not support setting connection pool size. #6374

Closed
happyzzz1997 opened this issue Sep 25, 2024 · 5 comments
Closed

kubernetesClient does not support setting connection pool size. #6374

happyzzz1997 opened this issue Sep 25, 2024 · 5 comments
Labels
Waiting on feedback Issues that require feedback from User/Other community members

Comments

@happyzzz1997
Copy link

I want to set the size of the connection pool, but the kubernetesClient does not support it. DefaultKubernetesClient(Config config) and DefaultKubernetesClient(HttpClient httpClient, Config config) create objects that look very different in implementation, how should I set the connection pool size?

@shawkins
Copy link
Contributor

This depends on the underlying http client implementation. More than likely you'll need to override the specific http client factory to do this. Can you elaborate on which http client you are using and why you need to set the pool size?

@manusa manusa added the Waiting on feedback Issues that require feedback from User/Other community members label Oct 8, 2024
@happyzzz1997
Copy link
Author

This depends on the underlying http client implementation. More than likely you'll need to override the specific http client factory to do this. Can you elaborate on which http client you are using and why you need to set the pool size?

I use the DefaultKubernetesClient(Config config) method to create a k8s client. I found that the client may continuously timeout when disk performance is poor or CPU frequency is unstable. I actively catch the exceptions that occur when using the client and close the connection, but it does not work. The exception continues until it recovers on its own, and the HTTP connection remains open during the fault period and is not closed as expected. I am not sure if the exception is related to this connection issue, so I want to set the connection pool size to 0 to create a new connection for each request.

@happyzzz1997
Copy link
Author

kubernetes version: 1.21.14
fabric8 version: 4.9.0

io.fabric8.kubernetes.client.KubernetesClientException: An error has occurred.
at io.fabric8.kubernetes.client.KubernetesClientException.launderThrowable(KubernetesClientException.java:64) ~[?:?]
at io.fabric8.kubernetes.client.KubernetesClientException.launderThrowable(KubernetesClientException.java:53) ~[?:?]
at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:248) ~[?:?]
at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:199) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:474) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:430) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:412) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.listRequestHelper(BaseOperation.java:151) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:621) ~[?:?]
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:70) ~[?:?]
at com.h3c.matrix.util.K8sClientHelper.getAllPods(K8sClientHelper.java:177) ~[?:?]
at com.h3c.matrix.monitor.util.MonitorUtil.getContainerResourceFromMetrics(MonitorUtil.java:1099) ~[?:?]
at com.h3c.matrix.monitor.main.LeaderOnlyMonitor.AlertManager.doMonitor(AlertManager.java:241) ~[?:?]
at com.h3c.matrix.monitor.main.LeaderOnlyMonitor.AlertManager.runOnce(AlertManager.java:213) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_322]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_322]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_322]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_322]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_322]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_322]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_322]
Caused by: java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:593) ~[?:?]
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:601) ~[?:?]
at okhttp3.internal.http2.Http2Stream$FramingSource.waitUntilReadable(Http2Stream.java:374) ~[?:?]
at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:337) ~[?:?]
at okhttp3.internal.http2.Http2Codec$StreamFinishingSource.read(Http2Codec.java:210) ~[?:?]
at okio.RealBufferedSource.read(RealBufferedSource.java:46) ~[?:?]
at okio.RealBufferedSource.request(RealBufferedSource.java:67) ~[?:?]
at okio.RealBufferedSource.require(RealBufferedSource.java:60) ~[?:?]
at okio.GzipSource.consumeHeader(GzipSource.java:114) ~[?:?]
at okio.GzipSource.read(GzipSource.java:73) ~[?:?]
at okio.RealBufferedSource$1.read(RealBufferedSource.java:430) ~[?:?]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[?:1.8.0_322]
at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[?:1.8.0_322]
at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:238) ~[?:?]
... 18 more

E0927 21:46:41.993869 1 wrap.go:54] timeout or abort while handling: GET "/api/v1/pods"
E0927 21:46:41.994160 1 writers.go:117] apiserver was unable to write a JSON response: http2: stream closed
{"level":"warn","ts":"2024-09-27T21:46:41.994+0900","caller":"clientv3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"endpoint://client-3f2a8b4a-85dc-430c-9e53-edad3c8b818d/matrix-node1:2379","attempt":0,"error":"rpc error: code = Canceled desc = context canceled"}
E0927 21:46:41.994256 1 status.go:71] apiserver received an error that is not an metav1.Status: &errors.errorString{s:"context canceled"}: context canceled
E0927 21:46:41.995375 1 status.go:71] apiserver received an error that is not an metav1.Status: &errors.errorString{s:"http2: stream closed"}: http2: stream closed
E0927 21:46:41.996591 1 writers.go:130] apiserver was unable to write a fallback JSON response: http2: stream closed
E0927 21:46:41.997747 1 writers.go:117] apiserver was unable to write a JSON response: http: Handler timeout
I0927 21:46:41.998940 1 trace.go:205] Trace[1245557671]: "SerializeObject" method:GET,url:/api/v1/pods,protocol:HTTP/2.0,mediaType:application/json,encoder:{"encodeGV":"v1","encoder":"{"name":"json","pretty":"false","yaml":"false"}","name":"versioning"} (27-Sep-2024 21:46:31.959) (total time: 10039ms):
Trace[1245557671]: ---"Write call finished" writer:*gzip.Writer,size:619863,firstWrite:true 10029ms (21:46:41.994)
Trace[1245557671]: [10.03949272s] [10.03949272s] END
I0927 21:46:41.998986 1 trace.go:205] Trace[1383485295]: "List" url:/api/v1/pods,user-agent:okhttp/3.9.1,client:127.0.0.1,accept:,protocol:HTTP/2.0 (27-Sep-2024 21:46:31.955) (total time: 10043ms):
Trace[1383485295]: ---"Writing http response done" count:66 10039ms (21:46:41.998)
Trace[1383485295]: [10.04351861s] [10.04351861s] END

@shawkins
Copy link
Contributor

Do you mean version 4.9? If so please update to a much later version.

As for the timeout exception, I can't really say at first glance what that is related to, and especially if changing the connection pool size would matter. Please reproduce whatever behavior you are seeing the latest version of the client as possible and re-open or re-create an issue.

@shawkins shawkins closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
@happyzzz1997
Copy link
Author

Okay, I will upgrade to the latest version . Thank you for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on feedback Issues that require feedback from User/Other community members
Projects
None yet
Development

No branches or pull requests

3 participants