PagerDuty / terraform-provider-pagerduty

Terraform PagerDuty provider
https://www.terraform.io/docs/providers/pagerduty/
Mozilla Public License 2.0
203 stars 212 forks source link

provider 1.11.0 crashed when importing pagerduty_service_dependency #394

Open jbfavre opened 3 years ago

jbfavre commented 3 years ago

Hello, I experienced a provider crasah while trying to import a pagerduty_service_dependency resource.

What I declared in Terraform:

resource "pagerduty_service_dependency" "grafana_uses_uberproxy" {
  dependency {
    dependent_service {
      id   = "PHSCZD5" #module.services["grafana"].service_id
      type = "service"
    }
    supporting_service {
      id   = "PQ4FERM" #local.pagerduty["services/uberproxy/id"]
      type = "service"
    }
  }
}

Running the import command leads to a crash:

> terraform import pagerduty_service_dependency.grafana_use
s_uberproxy PHSCZD5.service.PQ4FERM
pagerduty_service_dependency.grafana_uses_uberproxy: Importing from ID "PHSCZD5.service.PQ4FERM"...
pagerduty_service_dependency.grafana_uses_uberproxy: Import prepared!
  Prepared pagerduty_service_dependency for import
pagerduty_service_dependency.grafana_uses_uberproxy: Refreshing state... [id=PHSCZD5.service.PQ4FERM]
╷
│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.
╵

Stack trace from the terraform-provider-pagerduty_v1.11.0 plugin:

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

goroutine 58 [running]:
github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.resourcePagerDutyServiceDependencyRead(0xc000242850, 0x1094dc0, 0xc0004d66e0, 0xc000242850, 0x0)
        github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_service_dependency.go:195 +0xf2
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000d6b00, 0xc000670a50, 0x1094dc0, 0xc0004d66e0, 0xc00000e348, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/helper/schema/resource.go:455 +0x12e
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc000106798, 0x136b930, 0xc00066acf0, 0xc000670780, 0xc000106798, 0xc00066acf0, 0xc000652ba0)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/helper/plugin/grpc_provider.go:525 +0x3dd
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x10de6e0, 0xc000106798, 0x136b930, 0xc00066acf0, 0xc0002b65a0, 0x0, 0x136b930, 0xc00066acf0, 0xc000602380, 0x62)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/tfplugin5/tfplugin5.pb.go:3153 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00035efc0, 0x13755f8, 0xc000783200, 0xc000294300, 0xc00020faa0, 0x195da10, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.33.2/server.go:1210 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00035efc0, 0x13755f8, 0xc000783200, 0xc000294300, 0x0)
        google.golang.org/grpc@v1.33.2/server.go:1533 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000710680, 0xc00035efc0, 0x13755f8, 0xc000783200, 0xc000294300)
        google.golang.org/grpc@v1.33.2/server.go:871 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.33.2/server.go:869 +0x1fd

Error: The terraform-provider-pagerduty_v1.11.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.

Please let me know if there's anything I can do to help

jbfavre commented 3 years ago

Actually, downgrading to provider 1.10.1 release gives the same result:

> terraform import pagerduty_service_dependency.grafana_use
s_uberproxy PQ4FERM.service.PHSCZD5
pagerduty_service_dependency.grafana_uses_uberproxy: Importing from ID "PQ4FERM.service.PHSCZD5"...
pagerduty_service_dependency.grafana_uses_uberproxy: Import prepared!
  Prepared pagerduty_service_dependency for import
pagerduty_service_dependency.grafana_uses_uberproxy: Refreshing state... [id=PQ4FERM.service.PHSCZD5]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs
│ may contain more details.
╵

Stack trace from the terraform-provider-pagerduty_v1.10.1 plugin:

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

goroutine 72 [running]:
github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.resourcePagerDutyServiceDependencyRead(0xc0001ae5b0, 0x10901a0, 0xc0003c8140, 0xc0001ae5b0, 0x0)
        github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_service_dependency.go:195 +0xf2
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000a0880, 0xc0001bb6d0, 0x10901a0, 0xc0003c8140, 0xc00011a6c8, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/helper/schema/resource.go:455 +0x12e
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00028a828, 0x13662b0, 0xc0001b0210, 0xc0001bb400, 0xc00028a828, 0xc0001b0210, 0xc00036eba0)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/helper/plugin/grpc_provider.go:525 +0x3dd
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x10d98a0, 0xc00028a828, 0x13662b0, 0xc0001b0210, 0xc000837560, 0x0, 0x13662b0, 0xc0001b0210, 0xc000581030, 0x62)
        github.com/hashicorp/terraform-plugin-sdk@v1.7.0/internal/tfplugin5/tfplugin5.pb.go:3153 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00033f6c0, 0x136ff78, 0xc0003fde00, 0xc0002b4200, 0xc00070e3c0, 0x1956a10, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.33.2/server.go:1210 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00033f6c0, 0x136ff78, 0xc0003fde00, 0xc0002b4200, 0x0)
        google.golang.org/grpc@v1.33.2/server.go:1533 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00028c1a0, 0xc00033f6c0, 0x136ff78, 0xc0003fde00, 0xc0002b4200)
        google.golang.org/grpc@v1.33.2/server.go:871 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.33.2/server.go:869 +0x1fd

Error: The terraform-provider-pagerduty_v1.10.1 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.
stmcallister commented 3 years ago

I do believe #376 addresses this issue. I merged that to master today, so it should be available in the next release of the provider. I hope to push that update early next week.

dobs commented 2 years ago

If this continued occurring after #376 it may now be fixed following #458 and released as part of 2.3.0 -- it turns out we had another potential segfault scenario.