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

Build going into inifinite loop on running mvn oc:build -Dorg.slf4j.simpleLogger.defaultLogLevel=trace` #1950

Closed
rohanKanojia opened this issue Nov 30, 2022 · 11 comments · Fixed by #2150
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Nov 30, 2022

Describe the bug

When trying to use KubernetesClient verbose logs, using org.slf4j.simpleLogger.defaultLogLevel=trace property, I'm seeing build goes into an infinite loop in OpenShift Maven Plugin oc:build goal. This seems to be happening during the OpenShift S2I build when BuildConfig is submitted to OpenShift APIServer.

Meanwhile, the Build Pod never seems to come out of this stage:

 $ oc get pods
NAME                           READY     STATUS     RESTARTS   AGE
random-generator-s2i-3-build   0/1       Init:0/2   0          6m29s

Eclipse JKube version

1.10.0

Component

OpenShift Maven Plugin

Apache Maven version

3.8.5

Gradle version

No response

Steps to reproduce

Run mvn oc:build -Dorg.slf4j.simpleLogger.defaultLogLevel=trace in your project in presence of an OpenShift Cluster.

Expected behavior

Build should succeed within 1-2 minutes with verbose logs

Runtime

OpenShift

Kubernetes API Server version

1.24.7

Environment

Linux

Eclipse JKube Logs

NFO: --> POST https://api.sandbox.example.com:6443/apis/build.openshift.io/v1/namespaces/rokumar-dev/buildconfigs/random-generator-s2i/instantiatebinary?name=random-generator-s2i&namespace=rokumar-dev h2
^CNov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Type: application/octet-stream
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Length: 21053952
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Expect: 100-continue
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Authorization: Bearer sha256~_NMvkcN6PqDi9ZaOw02_8NYOZj490UIG-UiRnmyGlNE
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: User-Agent: fabric8-kubernetes-client/6.1.1
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Host: api.sandbox.example.com:6443
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Connection: Keep-Alive
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Accept-Encoding: gzip
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: --> POST https://api.sandbox.example.com:6443/apis/build.openshift.io/v1/namespaces/rokumar-dev/buildconfigs/random-generator-s2i/instantiatebinary?name=random-generator-s2i&namespace=rokumar-dev h2
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Type: application/octet-stream
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Length: 21053952
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Expect: 100-continue
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Authorization: Bearer sha256~_NMvkcN6PqDi9ZaOw02_8NYOZj490UIG-UiRnmyGlNE
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: User-Agent: fabric8-kubernetes-client/6.1.1
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Host: api.sandbox.example.com:6443
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Connection: Keep-Alive
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Accept-Encoding: gzip
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: --> POST https://api.sandbox.example.com:6443/apis/build.openshift.io/v1/namespaces/rokumar-dev/buildconfigs/random-generator-s2i/instantiatebinary?name=random-generator-s2i&namespace=rokumar-dev h2
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Type: application/octet-stream
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Content-Length: 21053952
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Expect: 100-continue
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Authorization: Bearer sha256~_NMvkcN6PqDi9ZaOw02_8NYOZj490UIG-UiRnmyGlNE
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: User-Agent: fabric8-kubernetes-client/6.1.1
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Host: api.sandbox.example.com:6443
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Connection: Keep-Alive
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: Accept-Encoding: gzip
Nov 30, 2022 11:46:31 AM okhttp3.internal.platform.Platform log
INFO: --> POST https://api.sandbox.example.com:6443/apis/build.openshift.io/v1/namespaces/rokumar-dev/buildconfigs/random-generator-s2i/instantiatebinary?name=random-generator-s2i&namespace=rokumar-dev h2

Sample Reproducer Project

No response

Additional context

No response

@rohanKanojia rohanKanojia added the bug Something isn't working label Nov 30, 2022
@DhirajSardar
Copy link

Can You point me to some of resources so that I can contribute ?

@rohanKanojia
Copy link
Member Author

@DhirajSardar : Sorry, but this is not a good issue for newcomers. I would advise you to look into currently open issues with label help wanted, good first issue .

@DhirajSardar
Copy link

DhirajSardar commented Dec 3, 2022 via email

@rohanKanojia
Copy link
Member Author

@DhirajSardar : I've written a blogpost on this topic: https://rohaan.medium.com/how-to-contribute-to-eclipse-jkube-f3bc7f902bf4 . Could you please give it a read and see if it helps?

@rohanKanojia
Copy link
Member Author

I think there is some problem with instantiating BuildConfig during oc:build in trace log:

We try to upload file to OpenShift API server:

https://github.com/eclipse/jkube/blob/174d1897655b8af31637d79728169768d2cf8004/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/openshift/OpenshiftBuildService.java#L443-L445

but control is never returned. Checking BuildConfigOperationsImpl, it seems to be stuck waiting for response; future never seems to be getting satisfied.

@manusa
Copy link
Member

manusa commented Jan 18, 2023

This seems to be completely related to #2000

The following snippet is evaluated when the generic trace option is enabled:
https://github.com/fabric8io/kubernetes-client/blob/0b1e79660e8c59a2a0def7f7593bae8d2b02282b/httpclient-okhttp/src/main/java/io/fabric8/kubernetes/client/okhttp/OkHttpClientFactory.java#L75-L80

Since the bodies of the request and response are printed and cannot be reset, everything else fails.

We need to specifically disable tracing for that logger, or at least set the level to BASIC instead.

@rohanKanojia
Copy link
Member Author

@manusa : Is it possible to disable this logger for a class (BuildConfigOperationsImpl)?

@manusa
Copy link
Member

manusa commented Jan 18, 2023

It depends on the logger implementation, but it should be possible. In any case, I think that the logger that should be disabled is the one related to okhttp3.logging.HttpLoggingInterceptor.

-Dorg.slf4j.simpleLogger.log.okhttp3.logging.HttpLoggingInterceptor=BASIC or -Dorg.slf4j.simpleLogger.log.okhttp3.logging.HttpLoggingInterceptor=off might get the job done, but haven't tried it.

References:

@rohanKanojia
Copy link
Member Author

rohanKanojia commented Jan 18, 2023

Thanks, I just tried it and oc:build seems to work as expected

mvn oc:build -Dorg.slf4j.simpleLogger.log.okhttp3.logging.HttpLoggingInterceptor=off -Dorg.slf4j.simpleLogger.defaultLogLevel=trace  -Djkube.version=1.10.1

This works as well:

mvn oc:build -Dorg.slf4j.simpleLogger.log.okhttp3.logging.HttpLoggingInterceptor=BASIC -Dorg.slf4j.simpleLogger.defaultLogLevel=trace  -Djkube.version=1.10.1

@rohanKanojia
Copy link
Member Author

I also tried by hardcoding HttpLoggingInterceptor's level to BASIC in KubernetesClient and using 6.4-SNAPSHOT in jkube. This also seems to resolve this issue.

Should we make this change in KubernetesClient? Or shall we just add documentation/FAQ for this?

@manusa
Copy link
Member

manusa commented Jan 18, 2023

I also tried by hardcoding HttpLoggingInterceptor's level to BASIC in KubernetesClient and using 6.4-SNAPSHOT in jkube. This also seems to resolve this issue.

Should we make this change in KubernetesClient? Or shall we just add documentation/FAQ for this?

I'm not sure I'm following here.
The problem is that we conditionally add the HttpLoginInterceptor in the client in case it's level is set to TRACE (see the linked code in my previous response).
The only thing we can do from JKube is see if we can override this lever for this specific class in all cases, however, I'm not sure this is possible.

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Jan 18, 2023
…ems with KubernetesClient (eclipse-jkube#1950)

Add a workaround to forcefully set
`org.slf4j.simpleLogger.log.okhttp3.logging.HttpLoggingInterceptor`
property to `BASIC` to prevent OkHttp's HttpLoggingInterceptor to
interfere with KubernetesClient operations.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@rohanKanojia rohanKanojia moved this from In Progress to Review in Eclipse JKube Jan 18, 2023
@manusa manusa moved this from Review to Planned in Eclipse JKube Jan 23, 2023
@manusa manusa self-assigned this May 3, 2023
@manusa manusa moved this from Planned to In Progress in Eclipse JKube May 3, 2023
@manusa manusa moved this from In Progress to Review in Eclipse JKube May 4, 2023
@manusa manusa added this to the 1.13.0 milestone May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants