pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
126 stars 33 forks source link

Go panic from GetServer #3103

Closed jamie-at-arkifi closed 5 months ago

jamie-at-arkifi commented 6 months ago

What happened?

Tried to call get_server() on the coordinator of a Cluster

Example

import pulumi_azure_native.dbforpostgresql as apg

# ...

    cluster = apg.Cluster(
        f"{name}-cluster",
        # Stuff here
    )
    cname = cluster.server_names.apply(
        lambda names: [n for n in names if n.name.endswith('-c')][0]
    )
    coordinator = apg.get_server(env.resource_group.name, cname)
    panic: interface conversion: interface {} is map[string]interface {}, not string
    goroutine 43 [running]:
    github.com/pulumi/pulumi-azure-native/v2/provider/pkg/provider.(*azureNativeProvider).prepareAzureRESTInputs(0x14000aedc00, {0x105969cc7, 0x83}, {0x140008b6fc0, 0x3, 0x1400095ab80?}, {0x0, 0x0, 0x140007fef38?}, 0x102ca3ec4?, ...)
        /home/runner/work/pulumi-azure-native/pulumi-azure-native/provider/pkg/provider/provider.go:1608 +0x65c
    github.com/pulumi/pulumi-azure-native/v2/provider/pkg/provider.(*azureNativeProvider).Invoke(0x14000aedc00, {0x10ca01448, 0x14000ab75c0}, 0x1400095ab00)
        /home/runner/work/pulumi-azure-native/pulumi-azure-native/provider/pkg/provider/provider.go:330 +0xa20
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler.func1({0x10ca01448, 0x14000ab75c0}, {0x10c861ec0?, 0x1400095ab00})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.104.2/proto/go/provider_grpc.pb.go:500 +0x74
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x10ca01448, 0x14000ab7290}, {0x10c861ec0, 0x1400095ab00}, 0x1400090c460, 0x1400050e5d0)
        /home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x2e8
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler({0x10c9b9ee0?, 0x14000aedc00}, {0x10ca01448, 0x14000ab7290}, 0x1400090a680, 0x140004ffd20)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.104.2/proto/go/provider_grpc.pb.go:502 +0x12c
    google.golang.org/grpc.(*Server).processUnaryRPC(0x1400012ed20, {0x10ca01448, 0x14000ab71d0}, {0x10ca0f560, 0x14000682b60}, 0x140005f9560, 0x14000a5a180, 0x10d7af500, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.59.0/server.go:1343 +0xb8c
    google.golang.org/grpc.(*Server).handleStream(0x1400012ed20, {0x10ca0f560, 0x14000682b60}, 0x140005f9560)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.59.0/server.go:1737 +0x990
    google.golang.org/grpc.(*Server).serveStreams.func1.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.59.0/server.go:986 +0x88
    created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 60
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.59.0/server.go:997 +0x160

Output of pulumi about

CLI
Version      3.106.0
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME          VERSION
azure-native  2.29.0
azuread       5.47.1
python        unknown
random        4.15.1
tailscale     0.14.0

Host
OS       darwin
Version  14.3.1
Arch     arm64

This project is written in python: executable='/Users/jamie/.local/share/virtualenvs/blount-z19IO5O9/bin/python3' version='3.12.1'

Current Stack: organization/deborah/dev

TYPE                                                   URN
[REDACTED]

Found no pending operations associated with dev

Backend
Name           Jamies-MacBook-Pro.local
URL            file://~
User           jamie
Organizations
Token type     personal

Dependencies:
NAME                 VERSION
mypy-extensions      1.0.0
nodeenv              1.8.0
pip                  23.3.2
pulumi_azure_native  2.29.0
pulumi_azuread       5.47.1
pulumi_random        4.15.1
pulumi_tailscale     0.14.0
typing_extensions    4.9.0
xonsh                0.14.4

Pulumi locates its logs in /var/folders/wf/m1npswwj7013_hlxb2qx84j40000gn/T/ by default

Additional context

I'm ultimately trying to use Database and FirewallRule with my Cluster, but they want a server_name, not anything directly from the cluster.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

jamie-at-arkifi commented 6 months ago

Oh, I think I passed it a ServerNameItemResponse instead of a str. Which should cause a more helpful error?