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

[Bug]: port-forward for java remote debugger fails on first connect #6863

Open
har-cpol opened this issue Feb 18, 2025 · 1 comment
Open
Labels

Comments

@har-cpol
Copy link

Bug

Current behavior

I am deploying an application with sync mode enabled, and a port forward to connect the java remote debugger.

When connecting the java IDE to the remote JVM then the connection disconnects after about a second.
This only happens the first time - when connecting again the connection succeeds.

I suspect this is some racecondition in initialization of the port-forward on first connection.
On the first connect, I'm always getting twice the logs "Connecting to portforward...", followed by twice the logs "Connection from ... ended":
(The message "ended" appears about a second after connecting)

Image

On client side, I'm getting disconnected

Image

When connecting the second time, all works fine, and connect log only appears once (one additionl log line):

Image

To reproduce this behavior you must use a java client - I could not reproduce the issue with a telnet connection.

The issue does not occur if I configure the port-forward with kubectl instead.

Expected behavior

JVM remote debugger should initialize correctly from the first time.

Reproducible example

Uploading a zip that reproduces the example.
It will start a simple java app that prints some text in an infinite loop.
Java is started with remote debugging enabled and a port forward via 127.0.0.1:5005 --> 5005

To test:

  • run: garden -l=debug deploy portforward --sync portforward
  • Connect a java IDE remote debugger to 127.0.0.1:5005

portforward.zip

Workaround

  • use kubectl port-forward instead of garden port-forward
  • or retry connect upon failure.

Suggested solution(s)

From the logs I suspect a race condition - seems like 2 outgoing connections are being configured.

Additional context

Your environment

  • OS: linux (Fedora)
  • How I'm running Kubernetes: locally with k0s, also occurs on google GKE

garden version: 0.13.45
(also tried with latest yesterday, same result)

@har-cpol har-cpol added the bug label Feb 18, 2025
@10ko
Copy link
Member

10ko commented Feb 20, 2025

Hi @har-cpol, thanks for this very detailed report and for the repro, we'll take a look in the coming days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants