splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
102 stars 75 forks source link

Provider crashed while deleting saved search #145

Open cosmincrihan opened 1 year ago

cosmincrihan commented 1 year ago

Received the following error during an apply command, while terraform was trying to destroy a saved search object:

module.oracle_hosts_entities_search.splunk_saved_searches.savedsearch: Destroying... [id=oracle_hosts_entities_search]
itsi_entity.oracle_instance_entity["NAME_OF_ENTITY"]: Creation complete after 29s [id=648272e5-7c66-3642-2519-0934c662a5ec]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.
╵

Stack trace from the terraform-provider-splunk_v1.4.17 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 52 [running]:
github.com/splunk/terraform-provider-splunk/splunk.savedSearchesDelete(0xc0000963f0, {0xbc97c0, 0xc00000e140})
    github.com/splunk/terraform-provider-splunk/splunk/resource_splunk_saved_searches.go:1598 +0x374
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00064e1b0, 0xc0006ee370, 0xc00020d220, {0xbc97c0, 0xc00000e140})
    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource.go:283 +0x257
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000690000, 0xc00059fa48, 0xd148a1, 0xf)
    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/provider.go:294 +0x70
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000650048, {0xc000096000, 0x4b3fa6}, 0xc000096000)
    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/helper/plugin/grpc_provider.go:885 +0x7c5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xce27e0, 0xc000650048}, {0xe8a8d0, 0xc0004661b0}, 0xc0000a82a0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000438480, {0xe978a0, 0xc00067a180}, 0xc000214300, 0xc00056ce70, 0x13c5860, 0x0)
    google.golang.org/grpc@v1.27.1/server.go:1024 +0xd1e
google.golang.org/grpc.(*Server).handleStream(0xc000438480, {0xe978a0, 0xc00067a180}, 0xc000214300, 0x0)
    google.golang.org/grpc@v1.27.1/server.go:1313 +0xa56
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 +0xef

Error: The terraform-provider-splunk_v1.4.17 plugin crashed!

After the crash, trying the apply again with no code change seemed to have fixed it though. However, submitting the log here anyway.

anushjay commented 1 year ago

@cosmincrihan If you can provide a sample configuration (just the specific resource that fails would suffice) and the version of Splunk you're running it against that would be very helpful.

cosmincrihan commented 1 year ago

@anushjay I attached both the resource in the state file that failed to delete and the corresponding Terraform code. The version of Splunk used was 8.1.1.

savedsearch_object.zip