Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic after terraform fails to delete NetActuate server due to API permissions #19

Open
valscale opened this issue Jun 19, 2023 · 0 comments

Comments

@valscale
Copy link

We are using the NetActuate terraform provider to provision servers. We ran into a index out of range error in the NetActuate provider in the following situation:

  1. Generate an API key for a user that does not have permission to delete servers via API.
  2. Add a machine to the list of servers to be provisioned and run "terraform apply"
  3. Remove the machine from the list of servers and run "terraform apply"
  4. This correctly fails because the user didn't have the setting to allow deletion via API key (fine, no problem)
  5. Run terraform plan after this
  6. Get a panic in the NetActuate provider due to index out of range (message below)

It looks like the NetActuate terraform provider leaves something in an inconsistent state when the server deletion fails due to lack of API permissions, then on the next invocation it tries to look up a non-existent thing in a zero-length array or slice.

I am happy to provide more info, though I think it can be reproduced with the steps above.

Thanks for creating this great resource!

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Plugin did not respond
│ 
│   with module.netactuate_vms["derp1i"].netactuate_server.server,
│   on ../lib/netactuate_vm/vm.tf line 77, in resource "netactuate_server" "server":
│   77: resource "netactuate_server" "server" {
│ 
│ 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-netactuate_v0.2.2 plugin:

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

goroutine 23 [running]:
github.com/netactuate/terraform-provider-netactuate/netactuate.resourceServerRead({0x1018a7060?, 0x1400022e840?}, 0x140001e7780, {0x101884040?, 0x1400059d1d0})
        github.com/netactuate/terraform-provider-netactuate/netactuate/resource_server.go:268 +0x538
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x140004261c0, {0x1018a7060, 0x1400022e840}, 0xd?, {0x101884040, 0x1400059d1d0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x140004261c0, {0x1018a7060, 0x1400022e840}, 0x1400018a5b0, {0x101884040, 0x1400059d1d0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x468
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x140004b0bb8, {0x1018a7060?, 0x1400022e720?}, 0x1400004cf00)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x400
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x140000a43c0, {0x1018a7060?, 0x1400009bd40?}, 0x140004e2720)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x3e8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x101872100?, 0x140000a43c0}, {0x1018a7060, 0x1400009bd40}, 0x140002bc8c0, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140004c0000, {0x1018aaa60, 0x140004d81a0}, 0x14000360ea0, 0x140004be870, 0x101d1b1f0, 0x0)
        google.golang.org/[email protected]/server.go:1340 +0xb7c
google.golang.org/grpc.(*Server).handleStream(0x140004c0000, {0x1018aaa60, 0x140004d81a0}, 0x14000360ea0, 0x0)
        google.golang.org/[email protected]/server.go:1713 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x290

Error: The terraform-provider-netactuate_v0.2.2 plugin crashed!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant