delve icon indicating copy to clipboard operation
delve copied to clipboard

How to Debug Webhook Logic in Go using Delve (dlv dap)?

Open Rajahimansh3 opened this issue 7 months ago • 1 comments

Hi team,

I'm working on a Go project that implements Kubernetes admission webhooks (mutating/validating). These webhooks include logic for setting defaults and validations during object creation or updates. Objective:

I want to debug the webhook functions (like Default() and ValidateCreate()) using Delve, ideally with dlv dap in VS Code. My Setup: Go version: go1.23.3 linux/amd64 Delve version: latest VS Code Remote SSH

Launch Config: { "name": "Launch Package", "type": "go", "request": "launch", "mode": "debug", "program": "${fileDirname}", "env": { "ENABLE_WEBHOOKS": "false" } }

Problem: Even though I set breakpoints inside the webhook logic and launch the project using the above config, But the breakpoints do not get hit inside VS Code.

Question: What’s the recommended way to debug webhook functions (mutating/validating/defaulting) with Delve?

Any help, docs, or sample launch setups would be highly appreciated!

Thanks!

Rajahimansh3 avatar Jun 05 '25 13:06 Rajahimansh3

Please see the FAQ about breakpoints in complicated debugging environments.

If that doesn't help please explain this in terms I can understand: what's a kubernetes admission webhook, how is it different from a normal program, what's VSCode Remote SSH, where is the program you are debugging run, where is the source code you are looking at and why you are convinced that the breakpoints you set should be hit and include the logs specified in the FAQ.

aarzilli avatar Jun 07 '25 14:06 aarzilli

Closing, no feedback.

aarzilli avatar Aug 14 '25 17:08 aarzilli