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

Regression issue: Exception when using OpenShift/Kubernetes extensions and having an external Ansi dependency #15953

Closed
Sgitario opened this issue Mar 23, 2021 · 17 comments · Fixed by #17169
Assignees
Labels
area/kubernetes kind/bug Something isn't working
Milestone

Comments

@Sgitario
Copy link
Contributor

Sgitario commented Mar 23, 2021

Describe the bug

We are getting an exception when using the OpenShift/Kubernetes extensions and having a third party dependency like:

<dependency>
          <groupId>org.fusesource.jansi</groupId>
          <artifactId>jansi</artifactId>
          <version>2.3.2</version>
</dependency>

When we build our application, it fails with:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (default) on project openshift-quickstart: 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: AnsiLogger requires a PrintStream instance.
[ERROR] 	at io.dekorate.logger.AnsiLogger.check(AnsiLogger.java:82)
[ERROR] 	at io.dekorate.logger.AnsiLogger.info(AnsiLogger.java:59)
[ERROR] 	at io.dekorate.processor.SimpleFileReader.read(SimpleFileReader.java:51)
[ERROR] 	at io.dekorate.Session.lambda$readExistingResources$6(Session.java:291)
[ERROR] 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
[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:168)
[ERROR] 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
[ERROR] 	at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:122)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] 	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
[ERROR] 	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

This is a regression issue caused by this change.

Expected behavior

The application should work as before this change.

To Reproduce

Steps to reproduce the behavior:

  1. Create a Quarkus application using:
mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create     -DprojectGroupId=org.acme     -DprojectArtifactId=openshift-quickstart     -DclassName="org.acme.rest.GreetingResource"     -Dpath="/greeting" 
  1. Add an ansi dependency like:
<dependency>
            <groupId>org.fusesource.jansi</groupId>
            <artifactId>jansi</artifactId>
             <version>2.3.2</version>
        </dependency>

Additional context

The issue is that the AnsiLogger gets used instead of NoopLogger. But AnsiLogger is not initialized.

@Sgitario Sgitario added the kind/bug Something isn't working label Mar 23, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 23, 2021

/cc @geoand

@Sgitario
Copy link
Contributor Author

/cc @iocanel

@iocanel
Copy link
Contributor

iocanel commented Mar 23, 2021

I agree! The NullLogger should be used instead. This will probably need to be addressed on the dekorate side.

@iocanel iocanel self-assigned this Mar 23, 2021
@Sgitario
Copy link
Contributor Author

Sgitario commented Mar 23, 2021

/cc @iocanel

If you know any workaround (apart from not using the above dependency), please let me know. This is a blocker for building our test suite against main atm :(

@Sgitario
Copy link
Contributor Author

Any updates about this issue? I could not find any workaround in our side yet as it seems that it's also picking AnsiLogger when: https://github.com/dekorateio/dekorate/blob/7d9a96f0ba3c07983ed89db81b3c84dddfa63433/core/src/main/java/io/dekorate/LoggerFactory.java#L49

I could make it worked when setting LoggerFactory.setLogger(new NoopLogger()); at the beginning of the KubernetesProcessor.build method. Not saying this is the proper solution, but it needs to be addressed though.

Moreover, we raised another issue related to the same changes: #16089

cc @geoand @gsmet

@geoand
Copy link
Contributor

geoand commented Mar 29, 2021

@iocanel are you looking at this?
Is there some quick fix we can do in Quarkus?

@iocanel
Copy link
Contributor

iocanel commented Mar 29, 2021

@geoand @Sgitario: I haven't had the time to look at it and I won't manage to look at it before Thursday.

But, here are some thoughts for everyone that wants to go for a fix.
The extension is meant to be using the NoopLogger this was either broken in one of the recent refactorings, or the changes in dekorate 2.x no longer respect the set logger (the former seems more likely).

AFAIR, we were setting the NoopLogger just when we created the Session through the Session. If the code is removed, we should bring it back, if it no longer works, then LoggerFactory.setLogger(new NoopLogger()) is not a bad idea.

@geoand
Copy link
Contributor

geoand commented Mar 29, 2021

We already seem to have https://github.com/quarkusio/quarkus/blob/main/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java#L135.

Furthermore it doesn't seem like we can access Dekorate's logger any other way.

@Sgitario
Copy link
Contributor Author

We already seem to have https://github.com/quarkusio/quarkus/blob/main/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java#L135.

Furthermore it doesn't seem like we can access Dekorate's logger any other way.

Any updates about this issue?

Otherwise, are you ok if we fix it by:
"I could make it worked when setting LoggerFactory.setLogger(new NoopLogger()); at the beginning of the KubernetesProcessor.build method." ?

cc @iocanel @geoand

@geoand
Copy link
Contributor

geoand commented Apr 23, 2021

This one is really for @iocanel to decide

@rsvoboda
Copy link
Member

This is blocking us with https://github.com/quarkus-qe/quarkus-openshift-test-suite move to Quarkus 2.0.0 Alpha releases.

@geoand
Copy link
Contributor

geoand commented Apr 26, 2021

@iocanel what do you want to do about this one?

@pjgg
Copy link
Contributor

pjgg commented May 12, 2021

@geoand there is a new Dekorate minor release that include a patch for this issue:

https://github.com/dekorateio/dekorate/releases/tag/2.1.4

Could we upgrade Quarkus Upstream in order to include this lib version?

@geoand
Copy link
Contributor

geoand commented May 12, 2021

@pjgg can you first respond to dekorateio/dekorate#753 (comment) so we can be sure things are fixed?

@iocanel
Copy link
Contributor

iocanel commented May 12, 2021

@pjgg can you first respond to dekorateio/dekorate#753 (comment) so we can be sure things are fixed?

He responded via google chat. We are good to go!

@geoand
Copy link
Contributor

geoand commented May 12, 2021

Cool!

In the future, it would be great to record such outcomes on the issue for posterity :)

@geoand
Copy link
Contributor

geoand commented May 12, 2021

@iocanel are you planning on opening the PR to bump dekorate?

@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 12, 2021
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.

5 participants