onelogin / terraform-provider-onelogin

GNU General Public License v3.0
27 stars 19 forks source link

plugin crash, failed "plugin.(*GRPCProvider).ApplyResourceChange call" #83

Closed rjhornsby closed 1 year ago

rjhornsby commented 1 year ago

It's possible - likely even - that I've done something wrong in my TF code, but the output of the plugin crash specifically asks for a bug report.

The scenario is that I'm trying to set up a onelogin_saml_apps for AWS (connector id 30319). I imported the hand-configured saml app from OL, and then went to resolve the differences in my TF code to make it match. tf-plan runs fine, but it still shows some differences. The plugin crash happens when I try to tf-apply

Happy to provide more info, just not sure what else might be relevant/helpful.

 Error: Plugin did not respond
│
│   with onelogin_saml_apps.onelogin-admin,
│   on main.tf line 58, in resource "onelogin_saml_apps" "onelogin-admin":
│   58: resource "onelogin_saml_apps" "onelogin-admin" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-onelogin_v0.2.0 plugin:

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

goroutine 16 [running]:
github.com/onelogin/onelogin-go-sdk/pkg/services/apps.(*V2Service).pruneParameters(0x14000349200, 0x140004a4f00, 0x1400028e840, 0x1010ea1e0, 0x1400028e840)
    github.com/onelogin/onelogin-go-sdk@v1.1.20/pkg/services/apps/v2.go:175 +0xdc
github.com/onelogin/onelogin-go-sdk/pkg/services/apps.(*V2Service).Update(0x14000349200, 0x1400028e840, 0x14000425910, 0x14000116fb4, 0x14000425920)
    github.com/onelogin/onelogin-go-sdk@v1.1.20/pkg/services/apps/v2.go:142 +0x364
github.com/onelogin/terraform-provider-onelogin/onelogin.samlAppUpdate(0x14000500080, 0x1010ea060, 0x14000344d20, 0xffffffffffffffff, 0x140004a5798)
    github.com/onelogin/terraform-provider-onelogin/onelogin/resource_onelogin_saml_apps.go:136 +0x6c8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x140001bacc0, 0x1012362f8, 0x140001ae3c0, 0x14000500080, 0x1010ea060, 0x14000344d20, 0x0, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/resource.go:302 +0x5c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140001bacc0, 0x1012362f8, 0x140001ae3c0, 0x1400028b0a0, 0x1400084ec00, 0x1010ea060, 0x14000344d20, 0x0, 0x0, 0x0, ...)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/resource.go:404 +0x2c0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x1400012b1e8, 0x1012362f8, 0x140001ae3c0, 0x1400028d180, 0x140001ae3c0, 0x1011dfc40, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.4.3/helper/schema/grpc_provider.go:955 +0x6f8
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0x140004f5a00, 0x1012363a0, 0x140001ae3c0, 0x1400028aee0, 0x140004f5a00, 0x100e01470, 0x1011b9cc0)
    github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/server/server.go:332 +0x94
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1011dfc40, 0x140004f5a00, 0x1012363a0, 0x140001b2240, 0x1400026b860, 0x0, 0x1012363a0, 0x140001b2240, 0x14000212500, 0x200d)
    github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x1c8
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000226e00, 0x10123ddb8, 0x14000583980, 0x140001fe000, 0x140003bc540, 0x10161c840, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1194 +0x3e8
google.golang.org/grpc.(*Server).handleStream(0x14000226e00, 0x10123ddb8, 0x14000583980, 0x140001fe000, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1517 +0xa50
google.golang.org/grpc.(*Server).serveStreams.func1.2(0x14000116490, 0x14000226e00, 0x10123ddb8, 0x14000583980, 0x140001fe000)
    google.golang.org/grpc@v1.32.0/server.go:859 +0x94
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.32.0/server.go:857 +0x1f8

Error: The terraform-provider-onelogin_v0.2.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.
rjhornsby commented 1 year ago

Looks like there's a deeper issue with the provider. I can create resources just fine. However, if I do tf-plan immediately after, it shows wanting to change the onelogin_saml_apps resource and other AWS things chained to it. Doing tf-apply at this point leads to the crash.

That is to say, it isn't required to create resources with the provider, change the TF code and then try to apply those changes. The same TF code that just created a onelogin_saml_apps resource will show a delta and crash the OL provider.

Jmfwolf commented 1 year ago

We are in the process of standardizing our SDKs by using OpenAPI specifications. I have an OpenAPI generated terraform-provider-onelogin in prerelease if you would like t try it out. https://github.com/onelogin/terraform-provider-onelogin/tree/openapi

rjhornsby commented 1 year ago

This bug no longer applies with the uncoupling of the onelogin go SDK from the terraform provider. See also onelogin/onelogin-go-sdk#63.