-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: support metadata to start debugger in wait mode for g… #9105
base: main
Are you sure you want to change the base?
feat: support metadata to start debugger in wait mode for g… #9105
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
8e4f6c0
to
91bdebc
Compare
This is my top desired feature for skaffold. I hope the maintainers can take a look at this soon. |
…r debugger to be attached or not
2931f5a
to
82e162d
Compare
I am not sure why this PR doesn't get any attention from the maintainers, but I rebased it to resolve the conflicts with main. In my workflow, and I think I am not alone, I need a breakpoint as soon as the first line in main() so such a feature is crucial. |
@idsulik @tejal29 @nathanperkins @menahyouyeah @briandealwis @louisjimenez @plumpy @ChrisGe4 @alphanota @johannespfrang @katiexzhang @mattsanta @gsquared94 |
|
||
if dmd != nil { | ||
spec.wait = dmd.ShouldWait | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by default bools are false - is this set somewhere else? Otherwise, I think you could just delete the else clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in go sure bools are instantiated as false, but here not this one, again if you prefer this boolean to start with a false value I need to rename the wait
to continue
@@ -155,7 +163,7 @@ func extractDlvSpec(args []string) *dlvSpec { | |||
return nil | |||
} | |||
// delve's defaults | |||
spec := dlvSpec{apiVersion: 2, log: false, headless: false} | |||
spec := dlvSpec{apiVersion: 2, log: false, headless: false, wait: true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing the default behavior. Are you sure about that? This could instead by false by default and if someone wants to have wait as true, then they'd need to have the label or annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to start from true
as the default behaviour of dlv
is also to wait, this changes with the --continue
arg which makes the wait to false
(here) and the default behaviour of dlv. I can rename the wait
to continue
and have it start at false?!
@@ -207,7 +217,12 @@ func (spec dlvSpec) asArguments() []string { | |||
if spec.headless { | |||
args = append(args, "--headless") | |||
} | |||
args = append(args, "--continue", "--accept-multiclient") | |||
|
|||
if !spec.wait { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on L178, if the arg is "continue" you set spec.wait to false. Then here, if the value is false, you append the "--continue" arg. I'm trying to figure out why you need to do both. In other words, if spec.Wait is false, why does the --continue arg need to be added? Isn't that the default behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not getting entirely what you mean. In the previous code you start from an image entrypoint/cmd and you instantiate accordingly a dlvSpec
(we don't hold the args inside the dlvSpec
). Where here you generate from a dlvSpec
the appropriate cli command with args. This logic was already in place and not introduced by this PR 🙂
PS: the default of dlv
is to wait and not continue thus adding the --continue
is required
container := adapter.GetContainer() | ||
log.Entry(context.TODO()).Infof("Configuring %q for node.js debugging", container.Name) | ||
|
||
// try to find existing `--inspect` command | ||
spec := retrieveNodeInspectSpec(config) | ||
if spec == nil { | ||
spec = &inspectSpec{host: "0.0.0.0", port: portAlloc(defaultDevtoolsPort)} | ||
if dmd != nil { | ||
spec.brk = dmd.ShouldWait | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment - could you leave the else off since bool are by default false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replied to the same comment above 🙂
@@ -58,6 +59,20 @@ func TestDlvTransformerApply(t *testing.T) { | |||
debugConfig: types.ContainerDebugConfiguration{Runtime: "go", Ports: map[string]uint32{"dlv": 56268}}, | |||
image: "go", | |||
}, | |||
{ | |||
description: "basic with wait debugger", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "with wait enabled in the debugger metadata"
@@ -62,6 +63,21 @@ func TestJdwpTransformerApply(t *testing.T) { | |||
}, | |||
debugConfig: types.ContainerDebugConfiguration{Runtime: "jvm", Ports: map[string]uint32{"jdwp": 5005}}, | |||
}, | |||
{ | |||
description: "existing port with suspend debugger", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "with wait enabled in metadata"
@@ -72,6 +73,20 @@ func TestNodeTransformer_Apply(t *testing.T) { | |||
}, | |||
debugConfig: types.ContainerDebugConfiguration{Runtime: "nodejs", Ports: map[string]uint32{"devtools": 9229}}, | |||
}, | |||
{ | |||
description: "entrypoint with PATH and brk", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not sure what brk means I would say something like "entrypoint with PATH and wait enabled in debugger metadata"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the inspiration came from here, but sure I can change it 🙂
@@ -60,6 +61,20 @@ func TestPythonTransformer_Apply(t *testing.T) { | |||
debugConfig: types.ContainerDebugConfiguration{Runtime: "python", Ports: map[string]uint32{"dap": 5678}}, | |||
image: "python", | |||
}, | |||
{ | |||
description: "basic with wait debugger", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same comment on test description
Implements #4870:
skaffold.dev/debug-suspend
[docker deploy]skaffold.dev/debug-suspend
[k8s deploy]