quaint-librarian-5573401/19/2023, 11:24 PM
This starts up the Java server and also listens for incoming remote debugger client connections on port 5005. Then, in our garden.yaml for the service we have configuration like so:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -cp /app/app.jar
When launched in devMode, the port forwarding for port 10000 is in place, however multiple attempts to connect the remote debugger result in various forms of error "Unable to open debugger port (localhost:100000): java.io.IOException" and sometimes this includes "handshake failed - connection prematurely closed". If we keep retrying this, eventually it will successfully connect. Once connected, it will usually be able to re-connect again reliably after a disconnect for the duration of the pod's life. Initially - my thought was that there was some sort of lag between when the service was responding on port 80 (meaning the garden health check saw the service as up) and when the remote debugger was able to accept connections. HOWEVER - when I tried directly creating a kubectl port forward using a command like
services: - name: "service-x" command: - "java" - "-cp" - "/app/app.jar" devMode: command: - "java" - "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" - "-cp" - "/app/app.jar" sync:  ports: - name: http containerPort: 80 servicePort: 80 localPort: 8080 - name: debug-port containerPort: 5005 servicePort: 5005 localPort: 10000
the debugger is immediately and reliably able to connect as soon as the service is deployed.
kubectl port-forward service/service-x 50005:10001
quaint-dress-83101/23/2023, 1:50 PM
quaint-librarian-5573401/23/2023, 5:02 PM
bright-policeman-4362601/24/2023, 11:01 PM
Is there anything you can reuse from the configuration used in that old issue?
big-spring-1494501/26/2023, 11:32 AM
command line option) and compare the kubectl command with the command you're using? Also does the timing of Garden killing / re-starting the kubectl correlate with your disconnect behaviour? I have the feeling that Garden might not set up a port-forward to the service, but to the Pod directly, and thus it must restart it from time to time, but as it's easier for you to reproduce this I would be very happy if you could do a further analysis and point me at the lines of log that correlate with the behaviour that you noticed.
quaint-librarian-5573401/31/2023, 3:26 PM