Skip to content

InformerEventSource crashes with NPE on Tests #890

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

Closed
jonathanvila opened this issue Jan 31, 2022 · 5 comments · Fixed by #894
Closed

InformerEventSource crashes with NPE on Tests #890

jonathanvila opened this issue Jan 31, 2022 · 5 comments · Fixed by #894
Assignees

Comments

@jonathanvila
Copy link

Bug Report

We have a test suite, that needs a new namespace for everytest. For that we use a new instance of the Operator on every test, assigning a client and a configuration pointing to the recently created test namespace.

With the "usual" conf , without a QuarkusMain class starting the operator.... we get an NPE on the InformerEventSource .

2022-01-31 16:56:16,387 ERROR [io.fab.kub.cli.inf.cac.SharedProcessor] (OkHttp https://192.168.39.20:8443/...) Failed invoking io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource$1@153670b3 event handler: null: java.lang.NullPointerException at io.javaoperatorsdk.operator.processing.event.source.controller.ControllerResourceCache.get(ControllerResourceCache.java:55) at io.javaoperatorsdk.operator.processing.event.EventProcessor.submitReconciliationExecution(EventProcessor.java:143)

This is the branch with the 2 test classes : keycloak/keycloak#9625
Code -> operator/src/test/org/keycloak/operator/ClusterOperatorTest , OperatorE2EIT
NOTE : the code contains the QuarkusMain to avoid these NPE in the log . Btw, these NPE are not affecting the test result.

What did you do?

mvn clean verify
-Dquarkus.kubernetes.deployment-target=kubernetes
--no-transfer-progress -Dtest.operator.deployment=local

What did you expect to see?

No NPE in the log.

What did you see instead? Under which circumstances?

NPE in the log .

To solve it we have added a QuarkusMain class ( thinking that with this class then the automatic start of the operator would not happen ) and no longer the NPE appears.

Environment

Kubernetes cluster type: minikube 1.24

$ Mention java-operator-sdk version from pom.xml file
Quarkus Operator SDK 3.0.0-SNAPSHOT

$ java -version

openjdk 11.0.13
$ kubectl version

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"archive", BuildDate:"2021-07-22T00:00:00Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:35:25Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}

Possible Solution

Additional context

@csviri csviri self-assigned this Feb 1, 2022
@csviri
Copy link
Collaborator

csviri commented Feb 1, 2022

Hi @jonathanvila , this rings a bell, could you pls update to the newest version? of sdk 2.0.2?
cc @metacosm

@metacosm
Copy link
Collaborator

metacosm commented Feb 1, 2022

Why are you using 3.0.0-SNAPSHOT? Can you try with 3.0.2, please?

@jonathanvila
Copy link
Author

Tried with Quarkus Operator SDK 3.0.2 ( JOSDK 2.0.2 ) , with same result :

2022-02-01 10:33:25,557 ERROR [io.fab.kub.cli.inf.cac.SharedProcessor] (OkHttp https://192.168.39.20:8443/...) Failed invoking io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource$1@4c1c8397 event handler: null: java.lang.NullPointerException at io.javaoperatorsdk.operator.processing.event.source.controller.ControllerResourceCache.get(ControllerResourceCache.java:55) at io.javaoperatorsdk.operator.processing.event.EventProcessor.submitReconciliationExecution(EventProcessor.java:144) at io.javaoperatorsdk.operator.processing.event.EventProcessor.handleMarkedEventForResource(EventProcessor.java:135) at io.javaoperatorsdk.operator.processing.event.EventProcessor.handleEvent(EventProcessor.java:126) at io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource.lambda$propagateEvent$1(InformerEventSource.java:122) at java.base/java.lang.Iterable.forEach(Iterable.java:75)

@andreaTP
Copy link
Collaborator

andreaTP commented Feb 1, 2022

This issue could be coming from the Quarkus distribution, looks like that Application Lifecycle Events are fired up even during the Tests.

I found a possibly relevant PR: quarkusio/quarkus#15144
According to it we should set: quarkus.arc.test.disable-application-lifecycle-observers=true by default, but it doesn't look to be enough.

cc. @metacosm

@jonathanvila
Copy link
Author

As per our conversation , the problem was related to this line :
SharedIndexInformer<Deployment> deploymentInformer = client.apps().deployments().inAnyNamespace() <---------- .withLabels(Constants.DEFAULT_LABELS) .runnableInformer(0);
That has been solved with this code :
SharedIndexInformer<Deployment> deploymentInformer = client.apps().deployments().inNamespace(context.getConfigurationService().getClientConfiguration().getNamespace()) .withLabels(Constants.DEFAULT_LABELS) .runnableInformer(0);
@metacosm @csviri

@csviri csviri closed this as completed Feb 1, 2022
@csviri csviri linked a pull request Feb 1, 2022 that will close this issue
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 a pull request may close this issue.

4 participants