cloud-code-intellij icon indicating copy to clipboard operation
cloud-code-intellij copied to clipboard

Allow Controlling Port Forwarding

Open anthonyalayo opened this issue 3 years ago • 6 comments

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

anthonyalayo avatar Oct 21 '22 22:10 anthonyalayo

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

etanshaul avatar Oct 24 '22 19:10 etanshaul

Thank you! I updated the description for clarity.

anthonyalayo avatar Oct 24 '22 19:10 anthonyalayo

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 (https://github.com/GoogleContainerTools/skaffold/issues/4870).

etanshaul avatar Oct 24 '22 21:10 etanshaul

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 (https://github.com/GoogleContainerTools/skaffold/issues/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.

anthonyalayo avatar Oct 24 '22 21:10 anthonyalayo

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.

etanshaul avatar Oct 24 '22 22:10 etanshaul

Thank you!

anthonyalayo avatar Oct 24 '22 22:10 anthonyalayo