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

ManagedKubernetesClient configuration policy should be REQUIRE #3700

Closed
mattrpav opened this issue Dec 28, 2021 · 6 comments · Fixed by #3701
Closed

ManagedKubernetesClient configuration policy should be REQUIRE #3700

mattrpav opened this issue Dec 28, 2021 · 6 comments · Fixed by #3701
Milestone

Comments

@mattrpav
Copy link
Contributor

Describe the bug

ManagedKubernetesClient does not handle activate( ) method being called with null properties. The Configuration policy should be set to 'REQUIRE' in order to only activate when a config is present.

Fabric8 Kubernetes Client version

5.5.0

Steps to reproduce

  1. Deploy kubernetes-client in osgi w/o a config file
  2. Observe NPE
Caused by: java.lang.NullPointerException
	at io.fabric8.kubernetes.client.osgi.ManagedKubernetesClient.activate(ManagedKubernetesClient.java:143) ~[kubernetes-client-5.3.1-bundle.jar:?]
	... 73 more

Expected behavior

Do not try to activate a ManagedKubernetesClient without a configuration file

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.20.12

Environment

macOS

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

mattrpav added a commit to mattrpav/kubernetes-client that referenced this issue Dec 28, 2021
 - Prevent NPE when config does not exist
mattrpav added a commit to mattrpav/kubernetes-client that referenced this issue Jan 5, 2022
mattrpav added a commit to mattrpav/kubernetes-client that referenced this issue Jan 5, 2022
mattrpav added a commit to mattrpav/kubernetes-client that referenced this issue Jan 5, 2022
 - Prevent NPE when config does not exist
 - Fix karaf itests
@manusa manusa linked a pull request Jan 10, 2022 that will close this issue
11 tasks
manusa pushed a commit that referenced this issue Feb 15, 2022
 - Prevent NPE when config does not exist
 - Fix karaf itests
@manusa manusa added this to the 6.0.0 milestone Feb 15, 2022
@rohanKanojia
Copy link
Member

@mattrpav : I have a question in the context of #3864 . Do you have some reproducer project which I can try out and reproduce for ManagedOpenShiftClient?

@rohanKanojia
Copy link
Member

@mattrpav : I wanted to ask another question, Have you upgraded to Fabric8 Kubernetes Client 6.x version and checked whether this fix is working for you?

I'm trying to prepare a reproducer for #3864 but at the moment I'm getting this exception with ManagedKubernetesClient:

llPointerException - null]
[INFO] k8s: java.lang.NullPointerException: null
[INFO] k8s: 	at io.fabric8.kubernetes.client.osgi.NamespacedKubernetesClientAdapter.getClient(NamespacedKubernetesClientAdapter.java:120) ~[!/:?]
[INFO] k8s: 	at io.fabric8.kubernetes.client.osgi.NamespacedKubernetesClientAdapter.resources(NamespacedKubernetesClientAdapter.java:131) ~[!/:?]

I'm not sure whether I'm using ManagedKubernetesClient correctly or not. Could you please review my reproducer and provide some feedback ?

@mattrpav
Copy link
Contributor Author

@rohanKanojia I don't use OpenShift, so not sure how it'll behave.

I'm happy to test out 6.x-- it'll be a bit later this week. I've got 3 other oss fixes in the queue.

@rohanKanojia
Copy link
Member

rohanKanojia commented Sep 19, 2022

@mattrpav : You don't have to worry about OpenShift. I will fix that as part of #3864

My question is regarding your OSGI project setup in ManagedKubernetesClient (any rough code snippet would be super helpful). I can replicate that onto OpenShift. Could you please review my reproducer to see if's trying to reproduce correctly https://github.com/rohankanojia-forks/kubernetes-client-osgi-demo/blob/main/src/main/java/org/eclipse/jkube/quickstart/karaf/K8sBookGenerator.java#L42?

@rohanKanojia
Copy link
Member

@mattrpav : May I ask which OSGi framework are you using? I'm trying Apache Karaf. I'm trying to add ManagedKuberntesClient via org.osgi.service.component.annotations.Reference

  @Reference
  ManagedKubernetesClient kubernetesClient;

I've provided it in OSGI-INF/blueprint/camel-log.xml (not sure whether it's the right syntax)

    <bean id="kubernetesClient" class="io.fabric8.kubernetes.client.osgi.ManagedKubernetesClient" factory-method="activate">
        <argument value="java.util.Map" />
    </bean>

But I keep getting NullPointerException, it doesn't look like ManagedKubernetesClient is getting initialized or activated.

@rohanKanojia
Copy link
Member

@mattrpav : polite ping, Did you manage to find time to look into this? It would be really helpful if you could provide a simple reproducer .

The reproducer I prepared doesn't seem to be calling ManagedKubernetesClient.activate() method which results in NPE

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