pulumi / pulumi-openstack

An OpenStack Pulumi resource package, providing multi-language access to OpenStack
Apache License 2.0
54 stars 8 forks source link

Panic on provider configuration: `networking.Network`: `interface {} is nil, not map[string]interface {}` #654

Closed yellowhat closed 1 month ago

yellowhat commented 1 month ago

Describe what happened

Hi, with the latest release (4.1.0) I am getting the following error on creating a openstack.networking.Network:

Diagnostics:
  pulumi:pulumi:Stack (dev):
    panic: interface conversion: interface {} is nil, not map[string]interface {}
    goroutine 31 [running]:
    github.com/hashicorp/go-cty/cty.Value.GetAttr({{{0x1964f70?, 0xc000804cd0?}}, {0x0?, 0x0?}}, {0x16d471b, 0x8})
        /home/runner/go/pkg/mod/github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320/cty/value_ops.go:711 +0x2de
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.getOkExists(0x0?, {0x16d471b, 0x8})
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/util.go:334 +0x34
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.configureProvider(0x80?, {0x16de760, 0xf})
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/provider.go:591 +0xd4c
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.Provider.func1({0x16d1b3d?, 0x6?}, 0xc0001a2720?)
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/provider.go:439 +0x3c
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).Configure(0xc00078eba0, {0x1964d40, 0xc0001a2720}, 0xc00058e190)
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20240520223432-0c0bf0d65f10/helper/schema/provider.go:314 +0x222
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Configure({0xc00078eba0?, {0x0?, 0x0?, 0x0?}}, {0x1964d40, 0xc000154b40}, {0x1955d20?, 0xc00058e190})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.87.0/pkg/tfshim/sdk-v2/provider.go:107 +0xb2
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Configure(0xc0004cd980, {0x1964d40?, 0xc000154690?}, 0xc000724300)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.87.0/pkg/tfbridge/provider.go:866 +0x416
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Configure_Handler.func1({0x1964d40, 0xc000154690}, {0x160b260?, 0xc000724300})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.124.0/proto/go/provider_grpc.pb.go:540 +0x72
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x1964d40, 0xc0000c8870}, {0x160b260, 0xc000724300}, 0xc0006ae0c0, 0xc000761b18)
        /home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x3d0
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Configure_Handler({0x169d900?, 0xc0004cd980}, {0x1964d40, 0xc0000c8870}, 0xc000aac780, 0xc00003e2a0)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.124.0/proto/go/provider_grpc.pb.go:542 +0x135
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc00089e000, {0x1964d40, 0xc0003d4a50}, {0x196e660, 0xc00021e480}, 0xc0001f2900, 0xc000901c50, 0x25fb4c0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
    google.golang.org/grpc.(*Server).handleStream(0xc00089e000, {0x196e660, 0xc00021e480}, 0xc0001f2900)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 100
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x135

    panic: interface conversion: interface {} is nil, not map[string]interface {}
    goroutine 44 [running]:
    github.com/hashicorp/go-cty/cty.Value.GetAttr({{{0x1964f70?, 0xc00007b3d0?}}, {0x0?, 0x0?}}, {0x16d471b, 0x8})
        /home/runner/go/pkg/mod/github.com/hashicorp/go-cty@v1.4.1-0.20200414143053-d3edf31b6320/cty/value_ops.go:711 +0x2de
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.getOkExists(0x0?, {0x16d471b, 0x8})
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/util.go:334 +0x34
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.configureProvider(0x80?, {0x16de760, 0xf})
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/provider.go:591 +0xd4c
    github.com/terraform-provider-openstack/terraform-provider-openstack/v2/openstack.Provider.func1({0x16d1b3d?, 0x6?}, 0xc0004ddb00?)
        /home/runner/go/pkg/mod/github.com/terraform-provider-openstack/terraform-provider-openstack/v2@v2.1.0/openstack/provider.go:439 +0x3c
    github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).Configure(0xc0004de2a0, {0x1964d40, 0xc0004ddb00}, 0xc00036e000)
        /home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20240520223432-0c0bf0d65f10/helper/schema/provider.go:314 +0x222
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.Configure({0xc0004de2a0?, {0x0?, 0x0?, 0x0?}}, {0x1964d40, 0xc000399620}, {0x1955d20?, 0xc00036e000})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.87.0/pkg/tfshim/sdk-v2/provider.go:107 +0xb2
    github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Configure(0xc00030f980, {0x1964d40?, 0xc000399200?}, 0xc0002a0240)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.87.0/pkg/tfbridge/provider.go:866 +0x416
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Configure_Handler.func1({0x1964d40, 0xc000399200}, {0x160b260?, 0xc0002a0240})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.124.0/proto/go/provider_grpc.pb.go:540 +0x72
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x1964d40, 0xc000398d20}, {0x160b260, 0xc0002a0240}, 0xc0003ee1c0, 0xc0000107b0)
        /home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x3d0
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Configure_Handler({0x169d900?, 0xc00030f980}, {0x1964d40, 0xc000398d20}, 0xc000b60580, 0xc0004ff660)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.124.0/proto/go/provider_grpc.pb.go:542 +0x135
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc00035c800, {0x1964d40, 0xc000398c90}, {0x196e660, 0xc0001c6600}, 0xc0003c6480, 0xc0003d3b00, 0x25fb4c0, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
    google.golang.org/grpc.(*Server).handleStream(0xc00035c800, {0x196e660, 0xc0001c6600}, 0xc0003c6480)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 29
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x135

I would say that this is creating the issue.

Downgrading to 4.0.1 is a workaround.

Sample program

        openstack.networking.Network(
            "foo",
            name="foo",
            admin_state_up="true",
        )

Log output

No response

Affected Resource(s)

openstack.networking.Network

Output of pulumi about

CLI          
Version      3.127.0
Go Version   go1.22.5
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  command     1.0.1
resource  hcloud      1.19.2
resource  kubernetes  4.15.0
resource  openstack   4.1.0
language  python      unknown

Host     
OS       fedora
Version  40
Arch     x86_64

This project is written in python: executable='/usr/bin/python3' version='3.12.4'

Backend        
Name           b56884fc291a
URL            file:///data/dev
User           root
Organizations  
Token type     personal

Dependencies:
NAME               VERSION
ansible-core       2.16.8
argcomplete        3.3.0
kubernetes         30.1.0
pip                23.3.2
pulumi_command     1.0.1
pulumi_hcloud      1.19.2
pulumi_kubernetes  4.15.0
pulumi_openstack   4.1.0
wheel              0.41.2

Additional context

No response

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).

guineveresaenger commented 1 month ago

Hi @yellowhat - I'm so sorry you're encountering this.

I've reproduced this bug on my end and we are taking a look.

guineveresaenger commented 1 month ago

This issue is not limited to networking.Network. It's failing on networking.Router as well:

import * as openstack from "@pulumi/openstack";

const router1 = new openstack.networking.Router("router_1", {
    name: "my_router",
    adminStateUp: true,
    externalNetworkId: "f67f0d72-0ddf-11e4-9d95-e1f29f417e2f",
});

Other modules are failing also:


const basic = new openstack.database.User("basic", {
    name: "basic",
    instanceId: basicOpenstackDbInstanceV1.id,
    password: "password",
    databases: ["testdb"],
});
guineveresaenger commented 1 month ago

update: The change that is making this panic is "caused" by a newly added call to d.GetRawConfig().GetAttr(key) on the provider configuration. It appears that Pulumi's provider configuration isn't correctly implementing the config for this call, as at that point in the call stack, d.GetRawConfig() returns the following cty.NullVal:

d.GetRawConfig()=cty.NullVal(cty.Object(map[string]cty.Type{"allow_reauth":cty.Bool, "application_credential_id":cty.String, "application_credential_name":cty.String, "application_credential_secret":cty.String, "auth_url":cty.String, "cacert_file":cty.String, "cert":cty.String, "cloud":cty.String, "default_domain":cty.String, "delayed_auth":cty.Bool, "disable_no_cache_header":cty.Bool, "domain_id":cty.String, "domain_name":cty.String, "enable_logging":cty.Bool, "endpoint_overrides":cty.Map(cty.String), "endpoint_type":cty.String, "insecure":cty.Bool, "key":cty.String, "max_retries":cty.Number, "password":cty.String, "project_domain_id":cty.String, "project_domain_name":cty.String, "region":cty.String, "swauth":cty.Bool, "system_scope":cty.Bool, "tenant_id":cty.String, "tenant_name":cty.String, "token":cty.String, "user_domain_id":cty.String, "user_domain_name":cty.String, "user_id":cty.String, "user_name":cty.String}))

I have attempted to run this program with Terraform, and am not encountering this issue - this is a bug/missing functionality on our end for the provider config. I'll file an issue in the pulumi-terraform-bridge to identify and address the root cause.

A way to hotfix this provider might be to patch up this line to use the previous version's method; however, the new function getOkExists is called in many more places and may panic similarly on resources.

Unfortunately, we're currently unable to verify actual resource creation due to an issue with our openstack account. We expect this to resolve soon, and should be able to have an update.

We recommend that folks refrain from updating to this version of the provider in the meantime, and regret the trouble.

pulumi-bot commented 1 month ago

This issue has been addressed in PR #656 and shipped in release v4.1.1.