OpenVPN / terraform-provider-cloudconnexa

OpenVPN Terraform CloudConnexa provider
https://registry.terraform.io/providers/OpenVPN/cloudconnexa
Apache License 2.0
7 stars 2 forks source link

Provider crashes after deleting a user #38

Open pickgr opened 1 month ago

pickgr commented 1 month ago

This may be related to https://github.com/OpenVPN/terraform-provider-cloudconnexa/issues/3

After deleting a user, the provider crashes:

  with module.connexa.cloudconnexa_user.this["jdoe"],
│   on ../../modules/connexa/users.tf line 1, in resource "cloudconnexa_user" "this":
│    1: resource "cloudconnexa_user" "this" {
│ 
│ The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.
╵

Stack trace from the terraform-provider-cloudconnexa_v0.1.2 plugin:

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

goroutine 864 [running]:
github.com/OpenVPN/terraform-provider-cloudconnexa/cloudconnexa.resourceUserRead({0xd82b70?, 0xc00077e0f0?}, 0xc000365e80, {0xb69720?, 0xc0003e8d80})
    github.com/OpenVPN/terraform-provider-cloudconnexa/cloudconnexa/resource_user.go:155 +0x163
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0000d95e0, {0xd82b70, 0xc00077e0f0}, 0xd?, {0xb69720, 0xc0003e8d80})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:795 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000d95e0, {0xd82b70, 0xc00077e0f0}, 0xc00072e0d0, {0xb69720, 0xc0003e8d80})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0002dc2b8, {0xd82b70?, 0xc000351f20?}, 0xc0003bd740)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:667 +0x48a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0001e0b40, {0xd82b70?, 0xc000351620?}, 0xc000241080)
    github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov5/tf5server/server.go:775 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xc3d5a0?, 0xc0001e0b40}, {0xd82b70, 0xc000351620}, 0xc000365780, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:482 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000117000, {0xd82b70, 0xc000351590}, {0xd86d18, 0xc0001e6180}, 0xc000442480, 0xc0002e2a50, 0x1285328, 0x0)
    google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc000117000, {0xd86d18, 0xc0001e6180}, 0xc000442480)
    google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 15
    google.golang.org/grpc@v1.63.2/server.go:1030 +0x135

Error: The terraform-provider-cloudconnexa_v0.1.2 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.

::error::Terraform exited with code 1.

Please note it may be difficult for me to provide more data, reproduce or verify a fix as I don't have direct access to Connexa anymore.

sahaqaa commented 1 month ago

I will take a look and reply back

sahaqaa commented 1 month ago

I tried to create and delete user via simple resource and also did same with for_each construction - i was able to create and delete users without issues.

Also i tried to press "ctrl+c" during destroy procedure to stop it - provider didn't crashed, but shown next output:

Plan: 0 to add, 0 to change, 3 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

cloudconnexa_user.this["Usern_name1"]: Destroying... [id=username1@xxx]
cloudconnexa_user.this["User_name2"]: Destroying... [id=username2@xxx]
cloudconnexa_user.this["User_name3"]: Destroying... [id=username3@xxx]
^C
Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...

Stopping operation...
cloudconnexa_user.this["User_name3"]: Destruction complete after 1s
cloudconnexa_user.this["Usern_name1"]: Destruction complete after 1s
cloudconnexa_user.this["User_name2"]: Destruction complete after 2s
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: execution halted
│ 
│ 
╵

I was not able to reproduce crashing provider when deleting user