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

mvn k8s:debug does not work! #2436

Closed
Brantfang opened this issue Nov 9, 2023 Discussed in #2435 · 4 comments · Fixed by #2437
Closed

mvn k8s:debug does not work! #2436

Brantfang opened this issue Nov 9, 2023 Discussed in #2435 · 4 comments · Fixed by #2437
Assignees
Milestone

Comments

@Brantfang
Copy link

Discussed in #2435

Originally posted by Brantfang November 9, 2023
pom.xml

<plugin>
	<groupId>org.eclipse.jkube</groupId>
	<artifactId>kubernetes-maven-plugin</artifactId>
	<version>1.14.0</version>
</plugin>

minikube

Profile VM Driver Runtime IP Port Version Status Nodes Active
minikube docker docker 192.168.49.2 8443 v1.27.4 Running 1 *

log

brantfang ➜ ~/person-smart $ mvn k8s:debug -DskipTests
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< org.eu.brantfang:person-smart >--------------------
[INFO] Building person-smart 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- k8s:1.14.0:debug (default-cli) @ person-smart ---
[INFO] k8s: Using Kubernetes at https://192.168.49.2:8443/ in namespace null with manifest /home/vscode/person-smart/target/classes/META-INF/jkube/kubernetes.yml 
[INFO] k8s: Enabling debug on Deployment person-smart
[INFO] k8s: Updating Deployment person-smart with Debug variables in containers
[INFO] k8s: Updating Deployment from kubernetes.yml
[INFO] k8s: Updated Deployment: target/jkube/applyJson/default/deployment-person-smart-2.json
[INFO] k8s: No Active debug pod with provided selector and environment variables found! Waiting for pod to be ready...
[INFO] k8s: Waiting for debug pod with selector LabelSelector(matchExpressions=[], matchLabels={app=person-smart, provider=jkube, group=org.eu.brantfang}, additionalProperties={}) and environment variables {JAVA_DEBUG_SESSION=7796160194962155, JAVA_DEBUG_SUSPEND=true, JAVA_ENABLE_DEBUG=true}
[INFO] k8s:  [W] person-smart-54854d9984-bnqds status: Pending 
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Running Ready
[INFO] k8s:  [W] person-smart-54854d9984-bnqds status: Running Ready
[INFO] k8s:  [W] Debug Pod ready : person-smart-54854d9984-bnqds
[INFO] k8s: Starting port forwarding to port 5005 on pod person-smart-54854d9984-bnqds
[INFO] k8s: Port Forwarding started
[INFO] k8s: Now you can start a Remote debug session by using localhost and the debug port 5005
[INFO] k8s: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Running Ready
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Failed 
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Failed 
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Failed 
[INFO] k8s:  [W] person-smart-55986bc885-4h49c status: Failed : Pod Deleted

in pod jdb attch

[I have no name!@person-smart-54854d9984-bnqds deployments]$ jdb -attach 5005
java.net.ConnectException: Connection refused
        at java.base/sun.nio.ch.Net.connect0(Native Method)
        at java.base/sun.nio.ch.Net.connect(Net.java:579)
        at java.base/sun.nio.ch.Net.connect(Net.java:568)
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
        at java.base/java.net.Socket.connect(Socket.java:633)
        at jdk.jdi/com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:261)
        at jdk.jdi/com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:119)
        at jdk.jdi/com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:83)
        at jdk.jdi/com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:557)
        at jdk.jdi/com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:367)
        at jdk.jdi/com.sun.tools.example.debug.tty.Env.init(Env.java:63)
        at jdk.jdi/com.sun.tools.example.debug.tty.TTY.main(TTY.java:1113)

Fatal error:
Unable to attach to target VM.

in IDEA romte attach

vscode ➜ ~/person-smart $ jdb -attach 5005
java.io.IOException: handshake failed - connection prematurally closed
        at jdk.jdi/com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:142)
        at jdk.jdi/com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:255)
        at jdk.jdi/com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:119)
        at jdk.jdi/com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:83)
        at jdk.jdi/com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:547)
        at jdk.jdi/com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:356)
        at jdk.jdi/com.sun.tools.example.debug.tty.Env.init(Env.java:63)
        at jdk.jdi/com.sun.tools.example.debug.tty.TTY.main(TTY.java:1091)

Fatal error:
Unable to attach to target VM.

in pod log not found any -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 info

:: Spring Boot ::               (v2.7.17)
2023-11-09 03:31:04.264  INFO 1 --- [           main] o.e.b.smart.PersonSmartApplication       : Starting PersonSmartApplication v0.0.1-SNAPSHOT using Java 17.0.7 on person-smart-54854d9984-bnqds with PID 1 (/deployments/BOOT-INF/classes started by ? in /deployments)
2023-11-09 03:31:04.271  INFO 1 --- [           main] o.e.b.smart.PersonSmartApplication       : No active profile set, falling back to 1 default profile: "default"
2023-11-09 03:31:05.651  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2023-11-09 03:31:05.666  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-11-09 03:31:05.667  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.82]
2023-11-09 03:31:05.760  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-11-09 03:31:05.760  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1382 ms
2023-11-09 03:31:06.289  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2023-11-09 03:31:06.299  INFO 1 --- [           main] o.e.b.smart.PersonSmartApplication       : Started PersonSmartApplication in 2.902 seconds (JVM running for 3.399)
```</div>
@manusa manusa self-assigned this Nov 9, 2023
@manusa manusa moved this to In Progress in Eclipse JKube Nov 9, 2023
@manusa
Copy link
Member

manusa commented Nov 9, 2023

Everything you mention seems fine.
Let me try to reproduce.

@manusa
Copy link
Member

manusa commented Nov 9, 2023

OK, I'm able to reproduce.
It's odd because debug was working fine with other frameworks (I've been using it last week).

It might have to do with some of these specific conditions (Minikube, Spring Boot 2.7.17, Application port 8081)

❌ It's failing with:

  • Spring Boot with 1.15-SNAPSHOT (Minikube)
  • Spring Boot with 1.14.0 (Minikube)

✅ It's working with:

  • Spring Boot with 1.13.1 (Minikube)
  • Spring Boot with 1.13.1 and base image quay.io/jkube/jkube-java:0.0.20 (Minikube)
  • Quarkus with 1.15-SNAPSHOT (Minikube)
  • Quarkus with 1.14.0 (OpenShift)
  • Quarkus with 1.14.0 (Minikube)
  • Quarkus with 1.10.0 (Minikube)

It seems that at some point we've messed up the base image and the DEBUG options (and maybe more) are no longer picked up by the base image.

The base image is fine.

The problem relies on the Spring Boot Generator that's now triggering a different Entrypoint instead of relying on the base image run-java.sh command.

I'm not sure why the following lines were added in the first place, but they should be removed:

https://github.com/eclipse/jkube/blob/03cfc9119caf9a6dec066f3b2254b7dd185d6933/jkube-kit/jkube-kit-spring-boot/src/main/java/org/eclipse/jkube/springboot/generator/LayeredJarGenerator.java#L43-L48

@Brantfang
Copy link
Author

Amazing, I only changed the jkube version to 1.13.1 and it works fine now!

@manusa
Copy link
Member

manusa commented Nov 9, 2023

Amazing, I only changed the jkube version to 1.13.1 and it works fine now!

We're expecting a release later this week, we'll provide a fix for this.

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.

2 participants