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

quarkus-kubernetes java.lang.ClassNotFoundException: io.fabric8.kubernetes.api.model.GenericKubernetesResourceBuilder #19379

Closed
anthonydahanne opened this issue Aug 12, 2021 · 9 comments · Fixed by #23031
Assignees
Labels
area/kubernetes kind/bug Something isn't working
Milestone

Comments

@anthonydahanne
Copy link
Contributor

Describe the bug

The extension quarkus-kubernetes fails if I add a custom resource in src/main/kubernetes/kubernetes.yml with :

[INFO] --- quarkus-maven-plugin:2.1.2.Final:build (default) @ my ---
[INFO] [org.jboss.threads] JBoss Threads version 3.4.2.Final
[INFO] Checking for existing resources in: /Users/anthonydahanne/workspaces/my/src/main/kubernetes.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.150 s
[INFO] Finished at: 2021-08-12T13:30:53-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.1.2.Final:build (default) on project my: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.IllegalStateException: Failed to create builder for: class io.fabric8.kubernetes.api.model.GenericKubernetesResource
[ERROR]         at io.fabric8.kubernetes.api.builder.BaseFluent.builderOf(BaseFluent.java:30)
[ERROR]         at io.fabric8.kubernetes.api.model.BaseKubernetesListFluentImpl.addToItems(BaseKubernetesListFluentImpl.java:134)
[ERROR]         at io.fabric8.kubernetes.api.model.BaseKubernetesListFluentImpl.withItems(BaseKubernetesListFluentImpl.java:254)
[ERROR]         at io.dekorate.utils.Serialization.unmarshalAsList(Serialization.java:196)
[ERROR]         at io.dekorate.processor.SimpleFileReader.readYml(SimpleFileReader.java:78)
[ERROR]         at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
[ERROR]         at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
[ERROR]         at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
[ERROR]         at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1694)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[ERROR]         at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[ERROR]         at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
[ERROR]         at io.dekorate.processor.SimpleFileReader.findApplicableResources(SimpleFileReader.java:101)
[ERROR]         at io.dekorate.processor.SimpleFileReader.read(SimpleFileReader.java:52)
[ERROR]         at io.dekorate.Session.lambda$readExistingResources$6(Session.java:291)
[ERROR]         at java.base/java.util.Optional.ifPresent(Optional.java:178)
[ERROR]         at io.dekorate.Session.readExistingResources(Session.java:291)
[ERROR]         at io.dekorate.Session.generate(Session.java:281)
[ERROR]         at io.dekorate.Session.close(Session.java:248)
[ERROR]         at io.quarkus.kubernetes.deployment.KubernetesProcessor.lambda$build$4(KubernetesProcessor.java:165)
[ERROR]         at java.base/java.util.Optional.ifPresent(Optional.java:178)
[ERROR]         at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:123)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:831)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: java.lang.ClassNotFoundException: io.fabric8.kubernetes.api.model.GenericKubernetesResourceBuilder
[ERROR]         at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
[ERROR]         at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
[ERROR]         at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
[ERROR]         at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
[ERROR]         at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:455)
[ERROR]         at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:405)
[ERROR]         at java.base/java.lang.Class.forName0(Native Method)
[ERROR]         at java.base/java.lang.Class.forName(Class.java:375)
[ERROR]         at io.fabric8.kubernetes.api.builder.BaseFluent.builderOf(BaseFluent.java:27)
[ERROR]         ... 34 more
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Expected behavior

If I save this manifest in src/main/kubernetes/kubernetes.yml, the extension should concatenate this additionnal Kubernetes resource to the file located at: target/kubernetes/kubernetes.yml

Actual behavior

If I save this manifest in src/main/kubernetes/kubernetes.yml, the extension will consider it and then fails

How to Reproduce?

Using the extension:

 <dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-kubernetes</artifactId>
</dependency>

I was able to successfully generate Service and Deployment resources in a file located in target/kubernetes/kubernetes.yml

In my deployment environment, I also need to an Istio resource, that's looking like this:

---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: my-vs
spec:
  gateways:
    - my-default-ingressgw
  hosts:
    - my.domain.com
  http:
    - match:
        - uri:
            prefix: /
      route:
        - destination:
            host: my
            port:
              number: 80

Output of uname -a or ver

Darwin [email protected] 19.6.0 Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "16.0.1" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.1.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

@anthonydahanne anthonydahanne added the kind/bug Something isn't working label Aug 12, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 12, 2021

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Aug 12, 2021

cc @iocanel

@gastaldi
Copy link
Contributor

gastaldi commented Aug 25, 2021

Don't you need something like https://github.com/snowdrop/istio-java-api also to support the Istio resources? Maybe @metacosm may help here?

@anthonydahanne
Copy link
Contributor Author

well, I guess there are 2 ways to solve the issue:

  • no longer throw the exception, just ignore the fact that the resource doe snot exist, and append its yaml to kubernetes.yaml trustfully
  • add a library with necessary classes to the plugin classpath

I guess you suggest option 2 @gastaldi ?

@rasmushaglund
Copy link

How can I help with this? JKube seems to work with Istio.

How would we go about solving option 2? I'm not sure why GenericKubernetesResourceBuilder is not generated in this case. I think most of us would be happy with just being able to include a yaml file that is included, with no annotations and properties support.

@geoand
Copy link
Contributor

geoand commented Sep 29, 2021

cc @metacosm

@rasmushaglund
Copy link

If I get some pointers I can try to make a pull request, or should this be fixed in fabric8?

@ricardozanini
Copy link

no longer throw the exception, just ignore the fact that the resource doe snot exist, and append its yaml to kubernetes.yaml trustfully

I think this is a reasonable alternative since it will allow custom resources to be added to the kubernetes.yml file. Sometimes we won't have the model/builders for it.

Another alternative is to add an extension point for users to add their own builders/model for custom resources.

@iocanel
Copy link
Contributor

iocanel commented Jan 19, 2022

This can be made to work, by adding the istio-client as a dependency to the project.

Users reported success with: https://github.com/snowdrop/istio-java-api.
It is also likely to work with the istio extension of the fabric8 kubernetes-client which is now the new home of the project above.

This is a work around, the real solution is to change the KubernetesDeployer so that it does not require the resources to be fully supported by the client. AFAIR, the client offers the genericResource method that should address that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants