-
Notifications
You must be signed in to change notification settings - Fork 210
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
Add environment variable to better support skaffold debug #259
Conversation
`skaffold debug` uses heuristics to determine if an application can be debugged, as described here: https://skaffold.dev/docs/workflows/debug/ In it's current state, the application doesn't work with `skaffold debug` without one of the standard go-runtime env vars as explained in the docs.
@briandealwis fyi for review as well |
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.
That'll do the trick.
@simonz130 @averikitsch @grayside ptal. Thanks. |
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.
-
Does this mean the dlv tool can be removed?
-
While we can add the variable to the Dockerfile, it seems worth asking: should we inject this into the container when starting locally so there's one less thing specializing the Dockerfile for development vs. production?
-
Are their performance implications to this variable? Haven't played with this one much. If we want to guide developers to remove this when not debugging I can follow-up with commented instructions.
@briandealwis do you have any more insight into @grayside 's above questions? My understanding is that this is a commonly used Go setting.
It is a chicken/egg problem.
Yes, IntelliJ doesn't need this - it uses |
There’s a chicken-and-egg problem: Go programs can’t be identified from examining the container image metadata alone. So we can’t inject the variable. The The stack traces are emitted stderr, and so should be picked up by the container logging. |
@briandealwis so if we just set @grayside if you are concerned about other implications of adding this env var, then for now we can just set it to the default value (which is basically a noop). |
(I updated the PR to use |
I'm not as concerned about performance as I am about making sure we're communicating why we do things that are not standard practice. Is this setting needed for debug or a proxy to identify that we're running a go binary? If the latter, wouldn't it make sense to define a dedicated CLOUD_CODE_RUNTIME override variable for go or other edge cases? |
Yes, this is needed to identify that we are running a go binary and that we can debug it.
The hope is that we'd be able to debug most applications in their default state without having to add any extra stuff (like that override that you mention) . I can see how you may think though that we are doing the same thing by adding the |
It's pretty common for a golang Dockerfile to be multi-stage, copying the binary into an image without the go toolchain. Would |
We can't identify that a binary is a Go binary. We've considered introducing explicit means to configure the language runtime type (GoogleContainerTools/skaffold#2203) but this is somewhat intrusive. And as it's not uncommon to use one of several Go runtime-specific environment variable(s), particularly |
@simonz130 @grayside could we try to come to a resolution on this? It is blocking debugging support on our Cloud Run Go sample |
I realized I didn't address some of @grayside's questions/comments. Just to be clear:
Yes, providing we identify the image as being Go related via one of these environment variables (more below).
This is great idea.
There are no performance implications: the use of
Yes, these variables serve as a proxy identifier. It's not uncommon for containers to define these values, particularly Settling on an agreeable prefix is … difficult. This functionality is delivered in Skaffold and is used independently of Cloud Code. It's actually why I settled on using these proxy identifiers instead as they existed and were in use.
It works for multistage builds: |
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 proposed a change to add more context to this change. I think we need to:
- P1: Indicate why this variable is defined so developers don't remove it as a simplification and have a change to learn via reading the sample about skaffold debug.
- P2: Link to documentation about this variable so anyone less familiar has a direct line on researching how to use the value now that they have it in front of them.
Co-Authored-By: Adam Ross <[email protected]>
thanks @grayside . Change suggestion accepted. ptal. |
skaffold debug
uses heuristics to determine if an application can be debugged, as described here:https://skaffold.dev/docs/workflows/debug/
In it's current state, the Go CR hello-world app doesn't work with
skaffold debug
without one of the standard go-runtime env vars as explained in the docs.