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

fix (osgi) : Fix OSGi startup exceptions while using KubernetesClient/OpenShiftClient #4459

Merged
merged 2 commits into from Oct 5, 2022

Conversation

rohanKanojia
Copy link
Member

@rohanKanojia rohanKanojia commented Sep 28, 2022

Description

  • Remove ExtensionAdapter reference from ManagedKubernetesClient, no provider is exposed for ExtensionAdapter interface in kubernetes-client module. bindExtensionAdapter and bindExtensionAdapter are throwing NullPointerException during startup.
  • Add Provide-Capability field in openshift-client and other extensions bundle configurations in order to resolve SPIFly related NPE (reported in Errors in the Karaf platform logs #3890)

See also

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@rohanKanojia rohanKanojia marked this pull request as ready for review September 29, 2022 04:45
Comment on lines +36 to +40
<osgi.provide-capability>
osgi.serviceloader;
osgi.serviceloader=io.fabric8.kubernetes.client.extension.ExtensionAdapter,
io.fabric8.kubernetes.client.ServiceToURLProvider
</osgi.provide-capability>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be added to any extension that provides SPI capabilities.

rohanKanojia and others added 2 commits October 5, 2022 08:48
…ations

+ Add Provide-Capability field in openshift-client + extensions bundle
configurations in order to resolve SPIFly related NPE (reported in fabric8io#3890)

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
…lient

Remove ExtensionAdapter reference from ManagedKubernetesClient, no
provider is exposed for ExtensionAdapter interface in
kubernetes-client module. bindExtensionAdapter and
unbindExtensionAdapter are throwing NullPointerException during
startup.
@manusa manusa added this to the 6.2.0 milestone Oct 5, 2022
@manusa manusa added the changelog missing A line to changelog.md regarding the change is not added label Oct 5, 2022
@manusa manusa changed the title fix (openshift-client) : Fix OSGi startup exceptions while using KubernetesClient/OpenShiftClient fix (osgi) : Fix OSGi startup exceptions while using KubernetesClient/OpenShiftClient Oct 5, 2022
@sonarcloud
Copy link

sonarcloud bot commented Oct 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@manusa manusa merged commit 2ffd63c into fabric8io:master Oct 5, 2022
@manusa manusa removed the changelog missing A line to changelog.md regarding the change is not added label Oct 5, 2022
@spolti
Copy link

spolti commented Nov 3, 2022

Hi @manusa @rohanKanojia, We've found a issue with quarkus-kubernetes-client (version 2.14.0.CR1) where a Provider Not found issue is happening:

ERROR: Failed to start application (with profile prod)
java.util.ServiceConfigurationError: io.fabric8.kubernetes.client.extension.ExtensionAdapter: Provider io.fabric8.knative.client.KnativeExtensionAdapter not found

Do you guys think that it is related with this change?
Note: Adding a BuildProducer step, apparently has fixed the issue.

    @BuildStep
    void processKnative(BuildProducer<ServiceProviderBuildItem> spb) {
        spb.produce(new ServiceProviderBuildItem("io.fabric8.kubernetes.client.extension.ExtensionAdapter", KnativeExtensionAdapter.class.getName()));
    }

Is this the right way to have the knative client properly working in native mode, or should this fix be in the quarkus-kubernetes-client?

Thanks.

@rohanKanojia rohanKanojia deleted the pr/osgi-startup-failures branch November 4, 2022 05:15
@rohanKanojia
Copy link
Member Author

@spolti : I'm not entirely sure. Could you please provide complete stacktrace? As far as I remember this error was coming from SPIFly. Does it happen in your case as well?

@spolti
Copy link

spolti commented Nov 4, 2022

Hi @rohanKanojia, here us the stacktrace:

java.util.ServiceConfigurationError: io.fabric8.kubernetes.client.extension.ExtensionAdapter: Provider io.fabric8.knative.client.KnativeExtensionAdapter not found
	at java.util.ServiceLoader.fail(ServiceLoader.java:593)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1219)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:114)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
	at java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
	at java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
	at io.fabric8.kubernetes.client.impl.Adapters.discoverServices(Adapters.java:106)
	at io.fabric8.kubernetes.client.impl.Adapters.<init>(Adapters.java:51)
	at io.fabric8.kubernetes.client.impl.BaseClient.<init>(BaseClient.java:102)
	at io.fabric8.kubernetes.client.impl.KubernetesClientImpl.<init>(KubernetesClientImpl.java:191)
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at io.fabric8.kubernetes.client.KubernetesClientBuilder.build(KubernetesClientBuilder.java:79)
	at io.fabric8.kubernetes.client.DefaultKubernetesClient.<init>(DefaultKubernetesClient.java:98)
	at io.fabric8.kubernetes.client.DefaultKubernetesClient.<init>(DefaultKubernetesClient.java:60)
	at io.fabric8.kubernetes.client.DefaultKubernetesClient.<init>(DefaultKubernetesClient.java:56)
	at io.fabric8.kubernetes.client.DefaultKubernetesClient.<init>(DefaultKubernetesClient.java:48)
	at org.kie.kogito.addons.quarkus.k8s.KubeDiscoveryConfigSourceInterceptor.<init>(KubeDiscoveryConfigSourceInterceptor.java:42)
	at org.kie.kogito.addons.quarkus.k8s.config.ServiceDiscoveryConfigBuilder.configBuilder(ServiceDiscoveryConfigBuilder.java:27)
	at io.quarkus.runtime.configuration.ConfigUtils.configBuilder(ConfigUtils.java:197)
	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:69)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:122)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)

I am not sure what SPIFly is, but in my case, it is happening with custom service discovery that uses quarkus-kubernetes-client and the io.fabric8:knative-client.

In the current Quarkus version this issue is not happening, only with the 2.14.0.CR1 that uses the fabric8 6.2.

@manusa
Copy link
Member

manusa commented Nov 4, 2022

This has to do with SPI and not OSGi.

Have you reported this in the Quarkus repo?
We should tackle this there.

Note: Adding a BuildProducer step, apparently has fixed the issue.

I'm assuming that the issue is happening in native mode then. In this case we need to register any SPI provided implementations following the same pattern you showed.

@spolti
Copy link

spolti commented Nov 4, 2022

Hi @manusa,

This has to do with SPI and not OSGi.

Have you reported this in the Quarkus repo? We should tackle this there.

Not yet, before that I wanted to confirm if that is a issue, or for native we just need to add the Extension producer.

Note: Adding a BuildProducer step, apparently has fixed the issue.

I'm assuming that the issue is happening in native mode then. In this case we need to register any SPI provided implementations following the same pattern you showed.

Yes, it is native.
Should we add this BuildProducer to the quarkus-k8s-client or it is expected that we add manually?
If so, I can open the issue and maybe provide the fix using the example above.

@manusa
Copy link
Member

manusa commented Nov 7, 2022

The thing is that this is for the Knative extension, which AFAIR is not part of the Quarkus client distribution.
It's probably better to open the issue in the Quarkus Repo to discuss where the responsibility to declare the Service Provider Build Item lies, which seems like a gray area for me.

@spolti
Copy link

spolti commented Nov 7, 2022

sure, thanks @manusa.

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

Successfully merging this pull request may close these issues.

None yet

3 participants