GoogleCloudPlatform / cloud-code-vscode

Cloud Code for Visual Studio Code: Issues, Documentation and more
Other
414 stars 111 forks source link

Cloud Code debugging fails to forward debug port #747

Open cfiderer opened 1 year ago

cfiderer commented 1 year ago

Type: Bug

Context

I'm using VS Code with Docker for Desktop to develop a Kubernetes operator. Testing with the "hello-world" or "guestbook" samples works fine. But when I try to debug my own container, the connection to the dlv debugger fails to come up: I get strange error messages and an error pop-up from VS Code.

Port forwarding pod/irs-operator-76d8594b75-rxcp4 in namespace edgelm, remote port 56268 -> http://127.0.0.1:56269
[operator]2023-03-01T08:56:14Z error layer=rpc writing response:write tcp 127.0.0.1:56268->127.0.0.1:47372: use of closed network connection
Forwarding container irs-operator-76d8594b75-rxcp4/operator to local port 56269.
failed to port forward pod-irs-operator-76d8594b75-rxcp4-edgelm-56268, port 56269 is taken, retrying...
Streaming logs from pod: irs-operator-76d8594b75-rxcp4 container: operator

Checking the ports with lsof shows two kubectl processes doing port forwarding:

❯ lsof -i -n | grep 5626
kubectl.1 84478 d041725   10u  IPv4 0x4748802f6bdfa9d1      0t0  TCP 127.0.0.1:56268 (LISTEN)
kubectl.1 84478 d041725   11u  IPv6 0x4748802aa213c7e9      0t0  TCP [::1]:56268 (LISTEN)
kubectl.1 92817 d041725   10u  IPv4 0x4748802f6bf15c61      0t0  TCP 127.0.0.1:56269 (LISTEN)
kubectl.1 92817 d041725   11u  IPv6 0x4748802aa2156969      0t0  TCP [::1]:56269 (LISTEN)
❯ pstree -s skaffold
-+= 00001 root /sbin/launchd
 \-+= 85720 d041725 /Applications/Visual Studio Code.app/Contents/MacOS/Electron
   \-+- 85798 d041725 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-GB --service-sandbox-type=none --inspect-port=0 --user-data-dir=/Users/d041725/Library
     \-+- 88922 d041725 /Users/d041725/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin/skaffold debug -v info --port-forward --auto-build --auto-deploy --auto-sync --rpc-http-port 53721 --filename /Users/d041725/develop/ghe/edgelm/image-replication-service/skaffold.yaml
       \--- 92817 d041725 kubectl --context cf-test-elm --namespace edgelm port-forward --pod-running-timeout 1s --namespace edgelm pod/irs-operator-76d8594b75-rxcp4 56269:56268

How can I analyze this and get the debugger up to work?

PS: asking this question on the #cloud-code Slack channel seems not possible without an @google.com e-mail address.

Extension version: 1.21.3 VS Code version: Code 1.75.1 (Universal) (441438abd1ac652551dbe4d408dfcec8a499b8bf, 2023-02-08T21:34:59.000Z) OS version: Darwin arm64 22.3.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|4, 7, 9| |Memory (System)|32.00GB (0.07GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
glouischandra commented 1 year ago

Hi @cfiderer Thanks for the bug report, we'll take a look into this.