GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
318 stars 59 forks source link

Problem launching debug session #3115

Open briantopping opened 1 year ago

briantopping commented 1 year ago

Hello, thanks for your work on the plugin.

I have been struggling to raise a public build in Cloud Code IntelliJ debug. Everything works fine in IntelliJ without debug. The containers are loaded by Skaffold and the delve ports are there, but the IntelliJ debug sessions are opened and immediately closed. A dialog like this is presented once for each session. Screenshot 2022-11-23 at 7 03 14 AM

The build is in Go 1.19.3, leading up to this point there was an issue with the debug containers in Skaffold not being recent enough and log entries that indicated some kind of port reuse conflict. The Skaffold team was able to get me through the former and I changed the build to see if I could get through the latter. The port conflict was resolved, but the problem described above did not. The logs for such a session are at https://gist.github.com/briantopping/72d3e37d6eb6db276bc502bd21a43286. The session was manually stopped shortly after the dialog above is presented.

It is worth noting that with the changes above, I am able to get the VSC environment to run things without error.

To Reproduce

The instructions for bringing up the build are well-documented here or in the upstream repo this repo with the skaffold.yaml change is forked from. This build runs in KinD, so Docker is required. Generally, once the project is checked out:

  1. Make sure that your local setup is covered here. There are not a lot of them and they are generally installations using a package manager versus uncontained configuration or routing changes.
  2. I generally iterate with fresh builds from bash history with make kind-down && sleep 20 && make kind-up && cp example/gardener-local/kind/local/kubeconfig ~/.kube/config. You may want to change the last bit to merge the k8s context instead of overwrite.
  3. Set up the IntelliJ plugin against the environment:
    1. Image repository set to localhost:5001
    2. Set the run environment variables to the following. The LD_FLAGS are referenced from the existing build that is not fully thought through to run interactively like this so I've just copied them here from a random build, will clean it up later. The other two variables were getting set by the Makefile builds and I copied them over for completeness.
      LD_FLAGS=-X k8s.io/component-base/version.gitMajor=1 -X k8s.io/component-base/version.gitMinor=59+ -X k8s.io/component-base/version.gitVersion=v1.59.2-dev -X k8s.io/component-base/version.gitTreeState=dirty -X k8s.io/component-base/version.gitCommit=687710226e12c02722dcb6da5713903366d83cc7 -X k8s.io/component-base/version.buildDate=2022-11-14T14:27:59-07:00 -X k8s.io/component-base/version/verflag.programName=Gardener;SKAFFOLD_DEFAULT_REPO=localhost:5001;SKAFFOLD_PUSH=true
    3. Other than targeting the skaffold.yaml at the root of the directory and targeting the kubeconfig as it is documented in step 2 above, I have left other settings alone
  4. At this point, one should be able to launch the IJ debug configuration. The build will happen inside Skaffold, deploy to the local registry and everything should launch.

Please don't hesitate to reach out with questions or requests, hopefully everything was captured here and I can get on Slack for interactive help at any time. It's actually pretty easy to set up and I wouldn't want anyone who is taking the time to look at this to struggle with it.

etanshaul commented 1 year ago

@briantopping thanks for all of the details here. We'll investigate and update here once we have some findings.