Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Annotate panics with provider metadata and origin (#2871)
Recover panics in the bridged providers and emit them as engine error events with sufficient annotations about which provider, provider version, resource and method was responsible for the panic. Fixes #2844 While the bridged providers should never panic, some WIP semantic discrepancy between TF and Pulumi still occasionally results in panics. These changes accomplish two purposes. First, it is easier for maintainers to immediately narrow down a panic to a resource or function involved to attempt a repro. Second, it is easier to scan for panics in internal logs and attribute them to providers unambiguously. With these changes, an injected panic in pulumi-random looks as follows. It is unfortunately double-stated but the new error message correctly attributes it to the provider, resource and method: ``` pulumi up --yes ~/code/pulumi-random/examples/simple/ts Previewing update (anton-test-logging) View in Browser (Ctrl+O): https://app.pulumi.com/anton-pulumi-corp/simple-random/anton-test-logging/previews/3f77e6b6-287b-4115-8439-8a3e5f328f24 Type Name Plan Info + pulumi:pulumi:Stack simple-random-anton-test-logging create 4 errors; 3 warnings + ├─ random:index:RandomInteger integer create + ├─ random:index:RandomUuid uuid create ├─ random:index:RandomString string 2 errors + └─ random:index:RandomPet pet create Diagnostics: pulumi:pulumi:Stack (simple-random-anton-test-logging): warning: using pulumi-resource-random from $PATH at /Users/anton/code/pulumi-random/bin/pulumi-resource-random warning: using pulumi-resource-random from $PATH at /Users/anton/code/pulumi-random/bin/pulumi-resource-random warning: resource plugin random is expected to have version >=4.16.8, but has 4.0.0-alpha.0+dev; the wrong version may be on your path, or this may be a bug in the plugin error: Detected that /Users/anton/code/pulumi-random/bin/pulumi-resource-random exited prematurely. This is *always* a bug in the provider. Please report the issue to the provider author as appropriate. To assist with debugging we have dumped the STDOUT and STDERR streams of the plugin: panic: FAILUREZ [recovered] panic: FAILUREZ goroutine 27 [running]: github.com/pulumi/pulumi-terraform-bridge/v3/pkg/providerserver.(*PanicRecoveringProviderServer).Check.func1() /Users/anton/code/pulumi-terraform-bridge/pkg/providerserver/panic_recovering_provider.go:306 +0xc8 panic({0x1023e15e0?, 0x102779e50?}) /nix/store/lb8wx7xsk7vryjxbbf9wlj820pdfvnbj-go-1.23.3/share/go/src/runtime/panic.go:785 +0x124 github.com/pulumi/pulumi-random/provider/v4.Provider.func1({0x14000bbf440?, 0x14000783e00?}, 0x140008bc0c0?, 0x7?) /Users/anton/code/pulumi-random/provider/resources.go:69 +0x2c github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge.(*provider).CheckWithContext(0x14000a3a388, {0x102799b98?, 0x140007822a0?}, {0x14000720000, 0x5c}, 0x140007822d0, 0x14000782300, 0x0?, {0x140005000c0, 0x20, ...}, ...) /Users/anton/code/pulumi-terraform-bridge/pkg/pf/tfbridge/provider_check.go:60 +0x518 github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/internal/plugin.(*providerServer).Check(0x14000a2bb00, {0x102799b98, 0x140007822a0}, 0x140007a0000) /Users/anton/code/pulumi-terraform-bridge/pkg/pf/internal/plugin/provider_server.go:366 +0x20c github.com/pulumi/pulumi-terraform-bridge/v3/pkg/providerserver.(*PanicRecoveringProviderServer).Check(0x1035943d0?, {0x102799b98?, 0x140007822a0?}, 0x1024133a0?) /Users/anton/code/pulumi-terraform-bridge/pkg/providerserver/panic_recovering_provider.go:309 +0x6c github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler.func1({0x102799b98?, 0x140007822a0?}, {0x1026a33a0?, 0x140007a0000?}) /Users/anton/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:855 +0xd0 github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x102799b98, 0x140007821b0}, {0x1026a33a0, 0x140007a0000}, 0x1400017c0a0, 0x14000c0a0f0) /Users/anton/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/go/otgrpc/server.go:57 +0x2d4 github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler({0x10272b000, 0x14000ba6780}, {0x102799b98, 0x140007821b0}, 0x14000284000, 0x14000a267c0) /Users/anton/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:857 +0x148 google.golang.org/grpc.(*Server).processUnaryRPC(0x14000b9c000, {0x102799b98, 0x14000782120}, {0x1027aabe0, 0x140007b8820}, 0x1400078c000, 0x14000a2bb90, 0x1035c0960, 0x0) /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1394 +0xb64 google.golang.org/grpc.(*Server).handleStream(0x14000b9c000, {0x1027aabe0, 0x140007b8820}, 0x1400078c000) /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1805 +0xb20 google.golang.org/grpc.(*Server).serveStreams.func2.1() /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1029 +0x84 created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 51 /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1040 +0x13c random:index:RandomString (string): error: Bridged provider panic (provider=random v=4.0.0-alpha.0+dev resourceURN=urn:pulumi:anton-test-logging::simple-random::random:index/randomString:RandomString::string method=Check): FAILUREZ goroutine 27 [running]: runtime/debug.Stack() /nix/store/lb8wx7xsk7vryjxbbf9wlj820pdfvnbj-go-1.23.3/share/go/src/runtime/debug/stack.go:26 +0x64 github.com/pulumi/pulumi-terraform-bridge/v3/pkg/providerserver.(*PanicRecoveringProviderServer).Check.func1() /Users/anton/code/pulumi-terraform-bridge/pkg/providerserver/panic_recovering_provider.go:303 +0x64 panic({0x1023e15e0?, 0x102779e50?}) /nix/store/lb8wx7xsk7vryjxbbf9wlj820pdfvnbj-go-1.23.3/share/go/src/runtime/panic.go:785 +0x124 github.com/pulumi/pulumi-random/provider/v4.Provider.func1({0x14000bbf440?, 0x14000783e00?}, 0x140008bc0c0?, 0x7?) /Users/anton/code/pulumi-random/provider/resources.go:69 +0x2c github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge.(*provider).CheckWithContext(0x14000a3a388, {0x102799b98?, 0x140007822a0?}, {0x14000720000, 0x5c}, 0x140007822d0, 0x14000782300, 0x0?, {0x140005000c0, 0x20, ...}, ...) /Users/anton/code/pulumi-terraform-bridge/pkg/pf/tfbridge/provider_check.go:60 +0x518 github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/internal/plugin.(*providerServer).Check(0x14000a2bb00, {0x102799b98, 0x140007822a0}, 0x140007a0000) /Users/anton/code/pulumi-terraform-bridge/pkg/pf/internal/plugin/provider_server.go:366 +0x20c github.com/pulumi/pulumi-terraform-bridge/v3/pkg/providerserver.(*PanicRecoveringProviderServer).Check(0x1035943d0?, {0x102799b98?, 0x140007822a0?}, 0x1024133a0?) /Users/anton/code/pulumi-terraform-bridge/pkg/providerserver/panic_recovering_provider.go:309 +0x6c github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler.func1({0x102799b98?, 0x140007822a0?}, {0x1026a33a0?, 0x140007a0000?}) /Users/anton/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:855 +0xd0 github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x102799b98, 0x140007821b0}, {0x1026a33a0, 0x140007a0000}, 0x1400017c0a0, 0x14000c0a0f0) /Users/anton/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/go/otgrpc/server.go:57 +0x2d4 github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler({0x10272b000, 0x14000ba6780}, {0x102799b98, 0x140007821b0}, 0x14000284000, 0x14000a267c0) /Users/anton/go/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider_grpc.pb.go:857 +0x148 google.golang.org/grpc.(*Server).processUnaryRPC(0x14000b9c000, {0x102799b98, 0x14000782120}, {0x1027aabe0, 0x140007b8820}, 0x1400078c000, 0x14000a2bb90, 0x1035c0960, 0x0) /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1394 +0xb64 google.golang.org/grpc.(*Server).handleStream(0x14000b9c000, {0x1027aabe0, 0x140007b8820}, 0x1400078c000) /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1805 +0xb20 google.golang.org/grpc.(*Server).serveStreams.func2.1() /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1029 +0x84 created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 51 /Users/anton/go/pkg/mod/google.golang.org/[email protected]/server.go:1040 +0x13c error: error reading from server: EOF ```
- Loading branch information