Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pkoutsovasilis
Copy link

@pkoutsovasilis pkoutsovasilis commented Sep 30, 2023

Implements #4870:

  • support for starting the respective runtime debugger in "wait" mode for go, python, nodejs, jvm if the container image has the label skaffold.dev/debug-suspend [docker deploy]
  • support for starting the respective runtime debugger in "wait" mode for go, python, nodejs, jvm if the pod template has the annotation the skaffold.dev/debug-suspend [k8s deploy]

@google-cla
Copy link

google-cla bot commented Sep 30, 2023

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.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 3, 2023
@pkoutsovasilis pkoutsovasilis changed the title feat: support docker image label to start debugger in wait mode for g… feat: support metadata to start debugger in wait mode for g… Oct 3, 2023
@anthonyalayo
Copy link

This is my top desired feature for skaffold. I hope the maintainers can take a look at this soon.

@pkoutsovasilis
Copy link
Author

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.

@mepi262
Copy link

mepi262 commented Dec 5, 2024

@idsulik @tejal29 @nathanperkins @menahyouyeah @briandealwis @louisjimenez @plumpy @ChrisGe4 @alphanota @johannespfrang @katiexzhang @mattsanta @gsquared94
Would someone review this pull request?


if dmd != nil {
spec.wait = dmd.ShouldWait
} else {
Copy link
Contributor

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.

Copy link
Author

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}
Copy link
Contributor

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

Copy link
Author

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 {
Copy link
Contributor

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?

Copy link
Author

@pkoutsovasilis pkoutsovasilis Dec 6, 2024

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 {
Copy link
Contributor

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?

Copy link
Author

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",
Copy link
Contributor

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",
Copy link
Contributor

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",
Copy link
Contributor

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"

Copy link
Author

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",
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants