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

Usage of Config.defaultClient(); is not longer valid in io.kubernetes:client-java-api:21.0.1 #3859

Open
Memo2782 opened this issue Jan 8, 2025 · 10 comments

Comments

@Memo2782
Copy link

Memo2782 commented Jan 8, 2025

Describe the bug
Looks like the references about how Fetch Config.defaultClient(); are not any longer valid from version 19 onward

Client Version
e.g. 21.0.1

Kubernetes Version
e.g. 21.0.1

Java Version
Java 8

To Reproduce
When i execute V1SecretList listSecret = new CoreV1Api(client).listNamespacedSecret(tlsInfo.getSecretsNamespace()
).execute();
when the code goes through the Class CoreV1Api at the section where the code is executed the references are timming out with the following error
{"instant":{"epochSecond":1736370513,"nanoOfSecond":362727400},"thread":"Test worker","level":"ERROR","loggerName":"ocpm.certificatemanagement.service.CertificatesProcessor","message":"API Exception occurred: Message: java.net.ConnectException: Failed to connect to /172.20.169.71:6443\r\nHTTP response code: 0\r\nHTTP response body: null\r\nHTTP response headers: null","thrown":{"commonElementCount":0,"localizedMessage":"Message: java.net.ConnectException: Failed to connect to /172.20.169.71:6443\r\nHTTP response code: 0\r\nHTTP response body: null\r\nHTTP response headers: null","message":"Message: java.net.ConnectException: Failed to connect to /172.20.169.71:6443\r\nHTTP response code: 0\r\nHTTP response body: null\r\nHTTP response headers: null","name":"io.kubernetes.client.openapi.ApiException","cause":{"commonElementCount":51,"localizedMessage":"Failed to connect to /172.20.169.71:6443","message":"Failed to connect to /172.20.169.71:6443","name":"java.net.ConnectException","cause":{"commonElementCount":51,"localizedMessage":"Connection timed out: no further information","message":"Connection timed out: no further information","name":"java.net.ConnectException","extendedStackTrace":"java.net.ConnectException: Connection timed out: no further information\n\tat java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]\n\tat java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[?:?]\n\tat java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]\n\tat java.base/java.net.Socket.connect(Socket.java:633) ~[?:?]\n\tat okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.12.0.jar:?]\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1028) ~[client-java-api-21.0.1.jar:?]\n"},"extendedStackTrace":"java.net.ConnectException: Failed to connect to /172.20.169.71:6443\n\tat okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.12.0.jar:?]\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1028) ~[client-java-api-21.0.1.jar:?]\nCaused by: java.net.ConnectException: Connection timed out: no further information\n\tat java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]\n\tat java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[?:?]\n\tat java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]\n\tat java.base/java.net.Socket.connect(Socket.java:633) ~[?:?]\n\tat okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.12.0.jar:?]\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1028) ~[client-java-api-21.0.1.jar:?]\n\t... 51 more\n"},"extendedStackTrace":"io.kubernetes.client.openapi.ApiException: Message: java.net.ConnectException: Failed to connect to /172.20.169.71:6443\r\nHTTP response code: 0\r\nHTTP response body: null\r\nHTTP response headers: null\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1032) ~[client-java-api-21.0.1.jar:?]\n\tat io.kubernetes.client.openapi.apis.CoreV1Api.listNamespacedSecretWithHttpInfo(CoreV1Api.java:27730) ~[client-java-api-21.0.1.jar:?]\n\tat io.kubernetes.client.openapi.apis.CoreV1Api$APIlistNamespacedSecretRequest.execute(CoreV1Api.java:27897) ~[client-java-api-21.0.1.jar:?]\n\tat ocpm.certificatemanagement.service.CertificatesProcessor.fetchSecrets(CertificatesProcessor.java:311) [main/:?]\n\tat ocpm.certificatemanagement.service.CertificatesProcessor.configureTls2(CertificatesProcessor.java:266) [main/:?]\n\tat ocpm.certificatemanagement.service.CertificatesProcessor.init(CertificatesProcessor.java:45) [main/:?]\n\tat ocpm.certificatemanagement.service.CertificateTest.test_init_ConfigureTLS_SecretNotFound(CertificateTest.java:95) [test/:?]\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:61) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) [junit-4.13.2.jar:4.13.2]\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:413) [junit-4.13.2.jar:4.13.2]\n\tat org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108) [gradle-testing-jvm-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:57) [gradle-testing-jvm-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39) [gradle-testing-jvm-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) [gradle-testing-jvm-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52) [gradle-testing-base-7.6.jar:7.6]\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]\n\tat org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) [gradle-messaging-7.6.jar:7.6]\n\tat org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) [gradle-messaging-7.6.jar:7.6]\n\tat org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) [gradle-messaging-7.6.jar:7.6]\n\tat org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) [gradle-messaging-7.6.jar:7.6]\n\tat jdk.proxy2/jdk.proxy2.$Proxy5.processTestClass(Unknown Source) [?:?]\n\tat org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176) [gradle-testing-base-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) [gradle-testing-base-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) [gradle-testing-base-7.6.jar:7.6]\n\tat org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) [gradle-testing-base-7.6.jar:7.6]\n\tat org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) [gradle-worker-processes-7.6.jar:7.6]\n\tat org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113) [gradle-worker-processes-7.6.jar:7.6]\n\tat org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65) [gradle-worker-processes-7.6.jar:7.6]\n\tat worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) [gradle-worker.jar:?]\n\tat worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) [gradle-worker.jar:?]\nCaused by: java.net.ConnectException: Failed to connect to /172.20.169.71:6443\n\tat okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.12.0.jar:?]\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1028) ~[client-java-api-21.0.1.jar:?]\n\t... 51 more\nCaused by: java.net.ConnectException: Connection timed out: no further information\n\tat java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]\n\tat java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549) ~[?:?]\n\tat java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[?:?]\n\tat java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]\n\tat java.base/java.net.Socket.connect(Socket.java:633) ~[?:?]\n\tat okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[okhttp-4.12.0.jar:?]\n\tat okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[okhttp-4.12.0.jar:?]\n\tat io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:1028) ~[client-java-api-21.0.1.jar:?]\n\t... 51 more\n"},"endOfBatch":false,"loggerFqcn":"org.apache.logging.slf4j.Log4jLogger","threadId":1,"threadPriority":5,"messageTimestamp":"2025-01-08T15:08:33.362-0600"}

Expected behavior
The behavir expected is that this code snippet behaves as this code
V1SecretList listSecret = new CoreV1Api(client).listNamespacedSecret(tlsInfo.getSecretsNamespace(), null, null,
null, null, null, null, null, null, null, null); that in the past used to fetch properly all the references

KubeConfig
It dependes of ApiClient references

Server (please complete the following information):

  • OS: [e.g. Linux] ApiClient References
  • Environment [e.g. container] ApiClient References
  • Cloud [e.g. Azure] ApiClient References

Additional context
Please provide documentation how this can be sorted out

@brendandburns
Copy link
Contributor

That looks like a network problem to me java.net.ConnectException: Failed to connect to /172.20.169.71:6443

Does kubectl work in the same environment?

@Memo2782
Copy link
Author

Memo2782 commented Jan 9, 2025

Hi @brendandburns looks like the client is being fetched in previous releases with ApiClient client = Config.defaultClient(); this is for version io.kubernetes', 'client-java').version('18.0.0'). For this is working fine. However for version 21.0.1 this sentence is not longer valid and is asking to fetch manually all references such as URL, Bearer-Token, and sslCACert such as this snippet represents LOGGER.info("Initializing Kubernetes API client");
//ApiClient client = initializeApiClient("https://172.20.169.71:6443");
ApiClient client = new ApiClient();
String kubeConfigPath = System.getProperty("user.home") + "/.kube/config";
String kubeConfigContent = new String(Files.readAllBytes(Paths.get(kubeConfigPath)));
client.setBasePath("https://172.20.169.71:6443");
client.addDefaultHeader("Authorization", "Bearer " + extractToken(kubeConfigContent));
i was trying to retrieve as much as information regarding the information above, but i guess this is not accurate at all. due Bearer-Token and sslCACert is being moved dinamically depending on the kubectl environment it is hosted. For that reason Config.defaultClient(), was the best approach to setup on our environments, problem as well is due the sentence execute at this stage
When i execute V1SecretList listSecret = new CoreV1Api(client).listNamespacedSecret(tlsInfo.getSecretsNamespace()
).execute();
The execute sentence goes through the execution through HTTP and i guess due the information regarding Bearer-Token and sslCACert is not well provided, for that reason is timing out.
Any workaoround to sort out Config.defaultClient();?

@brendandburns
Copy link
Contributor

Since you have a kubeconfig file, you should use:

ApiClient client = ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader(kubeConfigPath)).build()

Instead of trying to manually create it yourself.

If that doesn't work, please update with the error that you see and the contents of your kubeconfig (with the secrets redacted)

@Memo2782
Copy link
Author

Hi @brendandburns ClientBuilder is not part of io.kubernetes:client-java-api:21.0.1 references neither, i am using intellij to try to resolve it and it refer that it is not part of any references library already fetched
Captura de pantalla 2025-01-13 174042
Any other reference how to sort it out?

@brendandburns
Copy link
Contributor

I downloaded the jar file here: https://repo1.maven.org/maven2/io/kubernetes/client-java/21.0.1/client-java-21.0.1.jar

And ClientBuilder is in that jar file:

bburns@kube0:~$ unzip -l client-java-21.0.1.jar | grep ClientBuilder
     1142  2024-07-30 15:49   io/kubernetes/client/util/ClientBuilder$KubeConfigEnvParser.class
    13408  2024-07-30 15:49   io/kubernetes/client/util/ClientBuilder.class

So I think there must be some problem in your source code or otherwise.

@brendandburns
Copy link
Contributor

Ah, I think the problem is your dependency on client-java-api that's just the API objects.

You want:

<!-- https://mvnrepository.com/artifact/io.kubernetes/client-java -->
<dependency>
    <groupId>io.kubernetes</groupId>
    <artifactId>client-java</artifactId>
    <version>21.0.1</version>
</dependency>

@Memo2782
Copy link
Author

Hi @brendandburns thanks for the assistance, and yes the problem was this one, however when i try to setup a test set to fetch a supposed MockKuberenetes client with and trying to fetch the secrets to be retrieved in a second stage where it tries to retrieve them still sending socket timeout such as the client is not proper configured, i am placing the code with the problem just to figure out the problem it might be releated within `package ocpm.certificatemanagement.service;

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Secret;
import io.kubernetes.client.openapi.models.V1SecretList;
import io.kubernetes.client.util.Config;

import java.io.IOException;
import java.util.Base64;

public class GetKubernetesSecretsExample {
public static void main(String[] args) {
try {
// Load Kubernetes configuration
ApiClient client = Config.defaultClient();
io.kubernetes.client.openapi.Configuration.setDefaultApiClient(client);

        // Create the CoreV1Api instance
        CoreV1Api api = new CoreV1Api();

        // Specify the namespace
        String namespace = "default";

        // Fetch the list of Secrets in the namespace
        CoreV1Api.APIlistNamespacedSecretRequest secretList1 = api.listNamespacedSecret(namespace)
                .pretty(null)
                .allowWatchBookmarks(null)
                ._continue(null)
                .fieldSelector(null)
                .labelSelector(null)
                //.limit(Integer.MAX_VALUE)
                .resourceVersion(null)
                .resourceVersionMatch(null)
                .sendInitialEvents(null)
                .timeoutSeconds(null);

        // Print Secret names and data
        System.out.println("Secrets in namespace '" + namespace + "':");
        for (V1Secret secret : secretList1.execute().getItems()) {
            System.out.println("Name: " + secret.getMetadata().getName());

            if (secret.getData() != null) {
                System.out.println("Data:");
                secret.getData().forEach((key, value) -> {
                    // Secret data is Base64-encoded, so decode it
                    String decodedValue = new String(Base64.getDecoder().decode(value));
                    System.out.println("  " + key + ": " + decodedValue);
                });
            }
        }
    } catch (IOException e) {
        System.err.println("Failed to load Kubernetes configuration: " + e.getMessage());
    } catch (ApiException e) {
        System.err.println("API Exception: " + e.getResponseBody());
    }
}

}
`

@brendandburns
Copy link
Contributor

I would try removing .timeoutSeconds(null) but I'm not certain.

I don't think this is an issue with the client, so it is somewhat out of scope for this issues queue.

@Memo2782
Copy link
Author

@brendandburns i remove it and problem remains, could you suggest in which queue i can get some reference how to sort it out

Thanks in advance for your support

@Memo2782
Copy link
Author

Anyone can help on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants