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

Allow Controlling Port Forwarding #3110

Open
anthonyalayo opened this issue Oct 21, 2022 · 6 comments
Open

Allow Controlling Port Forwarding #3110

anthonyalayo opened this issue Oct 21, 2022 · 6 comments

Comments

@anthonyalayo
Copy link

anthonyalayo commented Oct 21, 2022

I have a spring boot java service using cloud code. I want to debug the server start sequence, but there is no way to do it.

Scenario 1

  1. Enable deployment checks on the cloud code run configuration
  2. Set the JVM arguments for debugging to not wait for the debug connection
  3. The port forwarding will be established after the server start sequence

Scenario 2

  1. Disable deployment checks on the cloud code run configuration
  2. Set the JVM arguments for debugging to wait for the debug connection
  3. The kubectl port forwarding will be attempted before the service is ready, and it will fail
  4. The server will start without any debugging capability

At present, how can I debug startup code in a server that occurs before readiness/liveness probes in cloud code?

If there was a button, or a delay, that I could configure for port forwarding to kick in, this would be solved. I could add suspend=y for the java debug agent, and have my port forwarding happen after X seconds.

Expected Behavior

I can control when port forwarding URLs occurs when using "Develop on Kubernetes".

Actual Behavior

I can not control when port forwarding URLs occurs when using "Develop on Kubernetes".

Additional Information

  • IDE type: IntelliJ IDEA
  • IDE version: 2022.2.3 (Ultimate Edition) Build #IU-222.4345.14, built on October 4, 2022
  • Cloud Code version (Settings > Plugins > Cloud Code): 22.10.1-222
  • Cloud SDK (Settings > Cloud Code > Cloud SDK)
    • Are you allowing the plugin to manage the Cloud SDK: No
    • Version of the Cloud SDK: 402.0.0
  • Skaffold version (If you are using Kubernetes features; Settings > Cloud Code > Kubernetes): v1.39.2
  • Operating System: MacOS 12.6
@etanshaul
Copy link
Contributor

@anthonyalayo thanks for the feature request. we will consider and triage this.

@anthonyalayo
Copy link
Author

Thank you! I updated the description for clarity.

@etanshaul
Copy link
Contributor

etanshaul commented Oct 24, 2022

Hi @anthonyalayo to see if you can get unblocked in the interim:

In scenario 2, disabling deployment checks as well as setting suspend=y were not sufficient to debug start up code? It seemed to work in my tests (using the Cloud Code supplied Java hello-world sample in the New Project wizard - https://github.com/GoogleCloudPlatform/cloud-code-samples/blob/v1/java/java-hello-world/kubernetes-manifests/hello.deployment.yaml#L26).

Of course port forwarding failed. But, I was then able to run kubectl port-forward [my-pod] 8080:8080 and debug the service itself. Not ideal, but at the moment Cloud Code doesn't have configurable port-forwarding as you observed. Also ideally Skaffold itself would support suspending (GoogleContainerTools/skaffold#4870).

@anthonyalayo
Copy link
Author

Of course port forwarding failed. But, I was then able to run kubectl port-forward [my-pod] 8080:8080 and debug the service itself. Not ideal, but at the moment Cloud Code doesn't have configurable port-forwarding as you observed.

I see, you manually port forwarded in a terminal after it failed. Was the IDE able to pick that up and hit breakpoints?

Also ideally Skaffold itself would support suspending (GoogleContainerTools/skaffold#4870).

Agreed, thanks for pointing out that ticket. Either or would solve the problem here. Considering that the linked issue was opened over 2 years ago, I have less confidence that Skaffold support would get implemented.

@etanshaul
Copy link
Contributor

Was the IDE able to pick that up and hit breakpoints?

yes it was.

I don’t know that there is a great solution here without Skaffold involvement. Skaffold controls the port-forwarding as well as the debug instrumentation (so making “suspend” configurable will require a change there too). I will check with them if any progress has been made.

@anthonyalayo
Copy link
Author

Thank you!

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

No branches or pull requests

3 participants
@etanshaul @anthonyalayo and others