Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Improvement : document how to debug a native provider with delve #2218

Closed
rouemma1 opened this issue Nov 11, 2022 · 6 comments · Fixed by #4006
Closed

Improvement : document how to debug a native provider with delve #2218

rouemma1 opened this issue Nov 11, 2022 · 6 comments · Fixed by #4006
Assignees
Labels
area/docs Improvements or additions to documentation kind/enhancement Improvements or new features resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Milestone

Comments

@rouemma1
Copy link

rouemma1 commented Nov 11, 2022

Problem description

Documentation of Pulumi doesn't cover how to attach a debugger to a running native provider written in Go. Being able to hook a debugger is mandatory during bug reproduction and problem diagnostic, or even to learn how to write native providers and inspect what a resource provider is expected to do.

Suggestions for a fix

Here's how to were able to achieve this.

It is possible to debug a Pulumi resource provider in Go using the PULUMI_DEBUG_PROVIDERS environment variable which tells Pulumi to use a provider that is already started. The format of the value to be supplied is: "providername:port,otherProvider:port". Note that the service port is returned when a provider is started.

Debugging with VS Code

From VS Code, it is possible to add a runtime configuration in the launch.json file to use Delve, the Go debugger.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Process",
            "type": "go",
            "request": "attach",
            "mode": "local",
            "processId": "${command:pickProcess}"
        },
        ...
    ]
}

Alternatively, it is possible to start Delve from the command line or from another IDE.

Disabling optimizations

Ideally one should get better results by compiling the project in debug and passing the following options -gcflags=all="-N -l" in order to disable optimizations so that the debugger is able to return the content of the stack and that function calls are not elided (inline).

References

Details of the Pulumi merge request

Visual Studio Code Golang Support

Visual Studio Code Golang debugging

@rouemma1 rouemma1 added the needs-triage Needs attention from the triage team label Nov 11, 2022
@susanev susanev transferred this issue from pulumi/docs Nov 12, 2022
@susanev
Copy link
Contributor

susanev commented Nov 12, 2022

@mikhailshilkov who is the best person to triage this?

@susanev susanev added area/docs Improvements or additions to documentation kind/enhancement Improvements or new features labels Nov 12, 2022
@thomas11
Copy link
Contributor

Thank you for submitting this idea, along with the correct instructions, @rouemma1!

We also have this documented internally in the providers team. It would be a matter of adding the relevant parts to the docs (and identifying to which docs).

@mikhailshilkov mikhailshilkov removed the needs-triage Needs attention from the triage team label Nov 16, 2022
@rouemma1
Copy link
Author

Thank you very much! Looking forward your version!

@ryan-pip
Copy link

Has there been any progress on this documentation? It would also be good to document how to get a native provider running so that we can connect to it, this seems to be missing from the instructions at the top.

@ericrudder ericrudder added this to the 0.94 milestone Sep 12, 2023
@ericrudder
Copy link
Member

@interurban can we pls try to knock this one out? thx

@mikhailshilkov mikhailshilkov modified the milestones: 0.94, 0.95 Oct 4, 2023
@mikhailshilkov mikhailshilkov removed this from the 0.95 milestone Oct 26, 2023
@interurban interurban added this to the 0.101 milestone Feb 26, 2024
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Mar 7, 2024
@interurban
Copy link
Collaborator

Hey@rouemma1 , give these new docs a try and let us know if you have any comments or suggestions.
https://www.pulumi.com/docs/using-pulumi/pulumi-packages/debugging-provider-packages/

@interurban interurban added the size/S Estimated effort to complete (1-2 days). label Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/docs Improvements or additions to documentation kind/enhancement Improvements or new features resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Projects
Status: 🏁 Done
Development

Successfully merging a pull request may close this issue.

8 participants