quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.56k stars 2.62k forks source link

When having Kubernetes extension + other Kubernetes based extensions together outputs lots of warnings during native build #34213

Open kjq opened 1 year ago

kjq commented 1 year ago

Describe the bug

When introducing the Tekton extension into a Quarkus project the following occurs:

Split package during compile (mvn install):

Detected a split package usage which is considered a bad practice and should be avoided. Following packages were detected in multiple archives:
- "io.fabric8.tekton.triggers.internal.knative.pkg.apis.duck.v1" found in [io.fabric8:tekton-model-triggers-v1alpha1::jar, io.fabric8:tekton-model-triggers-v1beta1::jar]
- "io.fabric8.tekton.triggers.internal.knative.pkg.apis" found in [io.fabric8:tekton-model-triggers-v1alpha1::jar, io.fabric8:tekton-model-triggers-v1beta1::jar]

Unresolved classes during native build (mvn package -Pnative): This seems to differ depending on the packages included.

When just Tekton is involved it is less but if the Kubernetes extension also happens to be there it is far more (enough to bog down the CI logs).

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

Just Tekton:

Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.

With Kubernetes extension:

Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.
Warning: Could not resolve io.fabric8.openshift.api.model.ImageStreamTagList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.ImageStreamTagList.
Warning: Could not resolve io.fabric8.openshift.api.model.ProjectList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.ProjectList.
Warning: Could not resolve io.fabric8.openshift.api.model.NetNamespaceList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.NetNamespaceList.
Warning: Could not resolve io.fabric8.openshift.api.model.UserList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.UserList.
Warning: Could not resolve io.fabric8.openshift.api.model.OAuthClientAuthorizationList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.OAuthClientAuthorizationList.
Warning: Could not resolve io.fabric8.openshift.api.model.LocalSubjectAccessReview for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.LocalSubjectAccessReview.
Warning: Could not resolve io.fabric8.openshift.api.model.RangeAllocation for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.RangeAllocation.
Warning: Could not resolve io.fabric8.openshift.api.model.User for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.User.
Warning: Could not resolve io.fabric8.openshift.api.model.TemplateInstanceList for reflection configuration. Reason: java.lang.ClassNotFoundException: io.fabric8.openshift.api.model.TemplateInstanceList.
...

Expected behavior

Native builds produce minimal or no warnings or the warnings can somehow be filtered out.

Actual behavior

So many warnings it makes it hard to review the CI logs.

How to Reproduce?

Reproduce the error:

  1. Run mvn package -Pnative

Not display all the warnings:

  1. Remove the kubernetes dependency from the POM
  2. run mvn package -Pnative

Output of uname -a or ver

No response

Output of java -version

17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

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

Maven 3.9

Additional information

This has not (or does not yet) seem to affect anything functionally.

quarkus-bot[bot] commented 1 year ago

/cc @Sgitario (kubernetes), @geoand (knative,kubernetes,openshift), @iocanel (knative,kubernetes,openshift)

kjq commented 1 year ago

Attached is a reproducer:

reproducer.zip

kjq commented 1 year ago

As an FYI, if i remove the direct dependency on the quarkus-kubernetes extension the quarkus-helm extension still will pull it in.

Sgitario commented 1 year ago

I think this issue got fixed using Fabric8 Kubernetes Client 6.7.2 (unless I can't see it anymore using Quarkus 999-SNAPSHOT):

Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatus: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/Addressable.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredConstructors for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.
Warning: Could not register io.fabric8.tekton.triggers.v1beta1.EventListenerStatusBuilder: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: io/fabric8/tekton/triggers/internal/knative/pkg/apis/duck/v1beta1/AddressableFluent.

About the rest of the warnings, I guess this is triggered by the Quarkus Kubernetes Client extension plus the Quarkus Tekton extension in the classpath: for some reason, the Quarkus Kubernetes Client extension tries to register those classes for reflection and they do not exist, but I could not see why it tries to register these classes, maybe @geoand can see it.

geoand commented 1 year ago

the Quarkus Kubernetes Client extension tries to register those classes for reflection and they do not exist, but I could not see why it tries to register these classes, maybe @geoand can see it

The only way would be to debug the build-time code that performs the reflection registration

Sgitario commented 1 year ago

Title updated since this's also happening when having the Kubernetes Config extension. cc @manusa @metacosm

manusa commented 1 year ago

Yes the Client should be registering any of the KubernetesResource classes that are detected (I'm assuming this is at the Jandex level and not with the changes introduced by #33767)

https://github.com/quarkusio/quarkus/blob/8a0624822e522cd438781ee786355a1ce41d7f54/extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/KubernetesClientProcessor.java#L150

What I find weird is that these classes are not found.

erik-wramner commented 1 year ago

I'm also getting tons of warnings for missing classes in packages io.fabric8.openshift and io.fabric8.knative. I'm pulling in quarkus-kubernetes-config and quarkus-kubernetes, but nothing from openshift or knative AFAIK. These warnings were not present in Quarkus 2, the came with the upgrade to 3 just now.

As long as it is only build time warnings it is not critical, but I don't like it. Perhaps they point to something that is wrong.

gsmet commented 1 year ago

@manusa did we make progress on this issue? We had another report today and, while not critical, it's not really pretty and people are asking about it.

manusa commented 1 year ago

The split package issue was addressed by https://github.com/fabric8io/kubernetes-client/issues/5113 (Is available on 6.8.0 - needs #34956)

The other issues might have been solved too, but would need to properly check once we bump the Kubernetes Client dependency version (https://github.com/fabric8io/kubernetes-client/pull/5345)

edeandrea commented 9 months ago

Adding onto this thread. I've started seeing this in the Quarkus superheroes sample application with the upgrade from 3.5.3 -> 3.6.0. I had not seen this before 3.5.3. Also, it's only happening in 1 of the apps (rest-fights).

All of the apps use multiple kubernetes extensions (kubernetes, openshift, minikube, knative).

See https://github.com/quarkusio/quarkus-super-heroes/actions/runs/7033441570/job/19139277699#step:6:5502 for the full log.

All the apps in the superheroes sample are different apps. Most expose a rest interface. The one in question uses mongodb (with liquibase) & smallrye stork, which is different from any of the other apps. Smallrye Stork in turn uses the kubernetes client.

This app also uses reactive messaging kafka, avro, & apicurio, but so does one of the other apps that does not seem to have this problem.

edeandrea commented 9 months ago

This seems to be an issue with the quarkus-kubernetes-client extension. If I add that extension to a different project I then start to see this issue.

What's interesting, though, is if I build with Java 21/GraalVM CE 21, I do not see the issue. Only with Java 17/GraalVM CE 17.