opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
106 stars 137 forks source link

Crash on destroy and subsequent plan if team and service are removed before incident rules #283

Open nitrocode opened 2 years ago

nitrocode commented 2 years ago

Terraform Version

terraform 1.0.8

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "opsgenie_team" "this" {
  name        = "example"
  description = "This team deals with all the things"
}

resource "opsgenie_service" "this" {
  name    = "Payment"
  team_id = opsgenie_team.this.id
}

resource "opsgenie_service_incident_rule" "this" {
  service_id = opsgenie_service.this.id
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

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.

Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-opsgenie_v0.6.7 plugin:

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

goroutine 82 [running]:
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.resourceOpsGenieServiceIncidentRuleRead(0xc00018d200, 0xbf89c0, 0xc0001302d8, 0x13095e0, 0x7f535e7b6218)
    github.com/opsgenie/terraform-provider-opsgenie/opsgenie/resource_opsgenie_service_incident_rule.go:212 +0x29a
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.handleNonExistentResource.func1(0xc00018d200, 0xbf89c0, 0xc0001302d8, 0x13095e0, 0xc000088800)
    github.com/opsgenie/terraform-provider-opsgenie/opsgenie/util.go:16 +0x47
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc00040cb60, 0xe49ab8, 0xc00028e580, 0xc00018d200, 0xbf89c0, 0xc0001302d8, 0x0, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:346 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00040cb60, 0xe49ab8, 0xc00028e580, 0xc00058edd0, 0xbf89c0, 0xc0001302d8, 0xc00060a228, 0x0, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:635 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00000c750, 0xe49ab8, 0xc00028e580, 0xc00028e5c0, 0xd50321, 0x12, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/grpc_provider.go:576 +0x47d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc00018c500, 0xe49b60, 0xc00028e580, 0xc0001e64e0, 0x0, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:553 +0x322
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0xd112e0, 0xc00018c500, 0xe49b60, 0xc0001c2360, 0xc0001e6480, 0x0, 0xe49b60, 0xc0001c2360, 0xc000776000, 0x1fb)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fec40, 0xe52058, 0xc000001800, 0xc000772400, 0xc0002945a0, 0x12ccbb0, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0001fec40, 0xe52058, 0xc000001800, 0xc000772400, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000038280, 0xc0001fec40, 0xe52058, 0xc000001800, 0xc000772400)
    google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

Error: The terraform-provider-opsgenie_v0.6.7 plugin crashed!

Expected Behavior

What should have happened?

Actual Behavior

What actually happened?

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform destroy

Important Factoids

Once I removed each opsgenie_service_incident_rule from the state, i was able to plan again

References

N/A

badtuxx commented 2 years ago

The same behavior using version 0.6.8.