kubernetes-client
kubernetes-client copied to clipboard
Upgrade from fabric8 kubernetes client from 6.9.2 to 6.10 gives error
Describe the bug
Upgrading from fabric8 kubernetes client from 6.9.2 to 6.10 gives the following stack trace:
java.lang.IllegalStateException: Failed to load ApplicationContext for [MergedContextConfiguration@61c4cebd testClass = my.project.service.testcontainer.UserAkhqServiceContainerTest, locations = [], classes = [my.project.UserAkHQApplication, my.project.service.testcontainer.helper.UserAkhqServiceTestConfig, my.project.service.testcontainer.StrimziContainerSetup], contextInitializerClasses = [], activeProfiles = ["container-test"], propertySourceDescriptors = [PropertySourceDescriptor[locations=[classpath:application-container-test.properties], ignoreResourceNotFound=false, name=null, propertySourceFactory=null, encoding=null]], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@659499f1, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@4310d43, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@242b836, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@1c7696c6, org.springframework.boot.test.context.SpringBootTestAnnotation@5891170b], contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:180)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:142)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:98)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260)
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initialiseStrimziAndKafka' defined in my.project.service.testcontainer.StrimziContainerSetup: Failed to instantiate [boolean]: Factory method 'initialiseStrimziAndKafka' threw exception with message: 'void io.fabric8.kubernetes.client.http.StandardHttpClient.<init>(io.fabric8.kubernetes.client.http.StandardHttpClientBuilder, java.util.concurrent.atomic.AtomicBoolean)'
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1165)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.la1mbda$doGetBean$0(AbstractBeanFactory.java:326)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1454)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:225)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:152)
... 15 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [boolean]: Factory method 'initialiseStrimziAndKafka' threw exception with message: 'void io.fabric8.kubernetes.client.http.StandardHttpClient.<init>(io.fabric8.kubernetes.client.http.StandardHttpClientBuilder, java.util.concurrent.atomic.AtomicBoolean)'
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
... 39 more
Caused by: java.lang.NoSuchMethodError: 'void io.fabric8.kubernetes.client.http.StandardHttpClient.<init>(io.fabric8.kubernetes.client.http.StandardHttpClientBuilder, java.util.concurrent.atomic.AtomicBoolean)'
at io.fabric8.kubernetes.client.okhttp.OkHttpClientImpl.<init>(OkHttpClientImpl.java:246)
at io.fabric8.kubernetes.client.okhttp.OkHttpClientBuilderImpl.completeBuild(OkHttpClientBuilderImpl.java:123)
at io.fabric8.kubernetes.client.okhttp.OkHttpClientBuilderImpl.initialBuild(OkHttpClientBuilderImpl.java:95)
at io.fabric8.kubernetes.client.okhttp.OkHttpClientBuilderImpl.build(OkHttpClientBuilderImpl.java:56)
at io.fabric8.kubernetes.client.okhttp.OkHttpClientBuilderImpl.build(OkHttpClientBuilderImpl.java:37)
at io.fabric8.kubernetes.client.KubernetesClientBuilder.getHttpClient(KubernetesClientBuilder.java:94)
at io.fabric8.kubernetes.client.KubernetesClientBuilder.build(KubernetesClientBuilder.java:79)
at my.project.component.KubernetesClientFactoryImp.getKubernetesClient(KubernetesClientFactoryImp.java:12)
at my.project.service.testcontainer.StrimziContainerSetup.createKubeConfigAndConnectClient(StrimziContainerSetup.java:100)
at my.project.service.testcontainer.StrimziContainerSetup.initialiseStrimziAndKafka(StrimziContainerSetup.java:156)
at my.project.service.testcontainer.StrimziContainerSetup$$SpringCGLIB$$0.CGLIB$initialiseStrimziAndKafka$1(<generated>)
at my.project.service.testcontainer.StrimziContainerSetup$$SpringCGLIB$$FastClass$$1.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at my.project.service.testcontainer.StrimziContainerSetup$$SpringCGLIB$$0.initialiseStrimziAndKafka(<generated>)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
... 40 more
I basically have this line of code where I'm getting a KubernetesClient from the Fabric8 API:
public KubernetesClient getKubernetesClient() { return new KubernetesClientBuilder().build(); }
Does this have to be done in a different way with the new version? I'm kind of puzzled and the stack trace is not really helping me to understand what's wrong.
Fabric8 Kubernetes Client version
6.10.0
Steps to reproduce
Make the following call:
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
KubernetesClientBuilder().build();
Expected behavior
A KubernetesClient is returned with no errors
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.24
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response