pulumi / pulumi-terraform-provider

Use any Terraform provider with Pulumi
Apache License 2.0
6 stars 0 forks source link

Provider plugin crashes on destroy #36

Closed praneetloke closed 2 weeks ago

praneetloke commented 1 month ago

What happened?

I dynamically generated a provider from https://github.com/Constellix/terraform-provider-constellix. I can create a resource just fine. When I try to delete the resource, the plugin crashes. I've tried to reproduce this issue with a TF program but it worked without issues, which leads me to believe there is something wrong in the bridge perhaps? Note that the resource is not actually deleted so the plugin seems to crash early. I have to go in to the Constellix console and manually remove the CNAME and refresh the state as a workaround.

error: rpc error: code = Unavailable desc = error reading from server: EOF:

    Stack trace from the terraform-provider-constellix_v0.4.6 plugin:

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc442e8]

    goroutine 41 [running]:
    github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc00000f218, {0xc00021d650, 0x4b4f86}, 0xc00021d650)
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:812 +0x1a8
    github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xe6b320, 0xc00000f218}, {0x1076d50, 0xc0003991a0}, 0xc000361320, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc00021b180, {0x1086918, 0xc000182900}, 0xc000310d00, 0xc0002f65d0, 0x1684ac0, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f
    google.golang.org/grpc.(*Server).handleStream(0xc00021b180, {0x1086918, 0xc000182900}, 0xc000310d00, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a
    google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.32.0/server.go:859 +0x98
    created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.32.0/server.go:857 +0x294

    Error: The terraform-provider-constellix_v0.4.6 plugin crashed!

    This is always indicative of a bug within the plugin. It would be immensely
    helpful if you could report the crash with the plugin's maintainers so that it
    can be fixed. The output above should help diagnose the issue

Example

import pulumi
import pulumi_constellix as constellix

config = pulumi.Config()

domain = config.require("domain")

constellix_domain = constellix.get_domain_output(name=domain)

cname = constellix.CnameRecord(
    "demo",
    domain_id=constellix_domain.apply(lambda d: d.id),
    host="google.com.",
    ttl=300,
    name="a-demo",
    noanswer=False,
    gtd_region=1,
    record_option="roundRobin",
    source_type="domains",
)

Output of pulumi about

CLI          
Version      3.134.0
Go Version   go1.23.1
Go Compiler  gc

Plugins
KIND      NAME                VERSION
resource  azure-native        2.62.0
resource  azuread             4.3.0
resource  kubernetes          4.17.1
language  python              unknown
resource  random              4.16.3
resource  terraform-provider  0.2.0
resource  tls                 4.11.1

Host     
OS       ubuntu
Version  20.04
Arch     x86_64

This project is written in python: executable='******' version='3.8.10' <--- Someone else reproduced the issue with 3.12 too.

Dependencies:
NAME                 VERSION
pip                  20.0.2
pkg-resources        0.0.0
pulumi-azure-native  2.62.0
pulumi-azuread       4.3.0
pulumi-constellix    0.4.6
pulumi-kubernetes    4.17.1
pulumi-random        4.16.3
pulumi-tls           4.11.1
setuptools           44.0.0

Additional context

Here's the equivalent TF program I used to check if the same issue occurs in TF.

terraform {
  required_providers {
    constellix = {
      source  = "Constellix/constellix"
    }
  }
}

provider "constellix" {
  apikey    = "xxxxxxx"
  secretkey = "xxxxxxxx"
  insecure  = true
}

data "constellix_domain" "domain1" {
  name = "<DOMAIN NAME>"
}

resource "constellix_cname_record" "demo" {
  name = "a-demo2"
  host = "google.com."
  ttl = 100
  noanswer = false
  gtd_region = 1
  record_option = "roundRobin"
  source_type = "domains"
  domain_id = "${data.constellix_domain.domain1.id}"
}

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 @praneetloke - thank you for sending this issue.

We'll be taking a look as soon as we can. It is certainly odd that the panic is happening in the terraform plugin; thank you very much for verifying the TF-only version of this.

praneetloke commented 1 month ago

@guineveresaenger just wondering if there is any other info I can gather to help diagnose this? Not sure if you've been able to reproduce the issue?

iwahbe commented 1 month ago

Hi @praneetloke. It's possible you could unblock us by giving us a state file that we can import and then run pulumi destroy on, so we could reproduce the panic. Depending on where the panic is, that might work. If we need real credentials, then that won't help.

I think that we need https://github.com/pulumi/pulumi-terraform-provider/issues/37 to gather enough information to act here in the general case. We have that issue scheduled for this iteration.

praneetloke commented 1 month ago

I've sent the state file privately to @iwahbe. Let me know if you need anything else to help diagnose this.

klis commented 3 weeks ago

Had the same issue now while trying to use generated provider from https://registry.terraform.io/providers/signalsciences/sigsci/latest

Diagnostics:
  sigsci:index:SiteRule (rule-test4):
    error: rpc error: code = Unavailable desc = error reading from server: EOF:

    Stack trace from the terraform-provider-sigsci_v3.3.0 plugin:

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbc9fd1]

    goroutine 91 [running]:
    github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000012128, {0xc0000f7110?, 0x4c05e6?}, 0xc0000f7110)
        github.com/hashicorp/terraform-plugin-sdk@v1.14.0/internal/helper/plugin/grpc_provider.go:802 +0x1b1
    github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xd9c460?, 0xc000012128}, {0xf578f0, 0xc00071a570}, 0xc0005f5020, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.14.0/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
    google.golang.org/grpc.(*Server).processUnaryRPC(0xc000428480, {0xf5b420, 0xc000328000}, 0xc0006b8d00, 0xc00051d470, 0x14921e0, 0x0)
        google.golang.org/grpc@v1.27.1/server.go:1024 +0xd4f
    google.golang.org/grpc.(*Server).handleStream(0xc000428480, {0xf5b420, 0xc000328000}, 0xc0006b8d00, 0x0)
        google.golang.org/grpc@v1.27.1/server.go:1313 +0xa25
    google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.27.1/server.go:722 +0x98
    created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.27.1/server.go:720 +0xea

    Error: The terraform-provider-sigsci_v3.3.0 plugin crashed!

    This is always indicative of a bug within the plugin. It would be immensely
    helpful if you could report the crash with the plugin's maintainers so that it
    can be fixed. The output above should help diagnose the issue.

Let me know if you need more details

iwahbe commented 3 weeks ago

Hi @klis. Thanks for letting us know. I've noticed that the crashing providers are all on SDKv1, which was last released 3 years ago. We only tested providers that are built on SDKv2 and Plugin Framework.

We are investigating how to enable pulumi-terraform-provider to work with SDKv1 built providers.