linode/terraform-provider-linode

[Bug]: Provider crash if instance is in recovery mode

devotoare opened this issue · 1 comments

Terraform Version

Terraform v1.6.4 on linux_amd64

Linode Provider Version

version = "2.10.0"

Effected Terraform Resources

linode_instance_config

Terraform Config Files

No response

Debug Output

No response

Panic Output

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


│ Error: Plugin did not respond

│ with linode_instance_config.nixos-config-installer,
│ on crater.tf line 38, in resource "linode_instance_config" "nixos-config-installer":
│ 38: resource "linode_instance_config" "nixos-config-installer" {

│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may
│ contain more details.


│ Error: Request cancelled

│ with linode_instance_config.nixos-config-main,
│ on crater.tf line 60, in resource "linode_instance_config" "nixos-config-main":
│ 60: resource "linode_instance_config" "nixos-config-main" {

│ The plugin.(*GRPCProvider).ReadResource request was cancelled.

Stack trace from the terraform-provider-linode_v2.10.0 plugin:

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

goroutine 456 [running]:
github.com/linode/terraform-provider-linode/linode/helper.GetCurrentBootedConfig({0x2695640, 0xc000a0f1a0}, 0xc0014ba8c0?, 0xc000dd2660?)
github.com/linode/terraform-provider-linode/linode/helper/instance.go:132 +0x540
github.com/linode/terraform-provider-linode/linode/instanceconfig.isConfigBooted({0x2695640?, 0xc000a0f1a0?}, 0xc000a0f1a0?, 0xc00105ca00, 0x34cbe4a)
github.com/linode/terraform-provider-linode/linode/instanceconfig/helper.go:304 +0x37
github.com/linode/terraform-provider-linode/linode/instanceconfig.readResource({0x2695608?, 0xc000a0ef90?}, 0xc000ac6c00, {0x1d040c0?, 0xc000e2c000})
github.com/linode/terraform-provider-linode/linode/instanceconfig/resource.go:97 +0x63d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc00050db20, {0x2695640, 0xc000661620}, 0xd?, {0x1d040c0, 0xc000e2c000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/resource.go:795 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00050db20, {0x2695640, 0xc000661620}, 0xc0007b4270, {0x1d040c0, 0xc000e2c000})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/resource.go:1089 +0x59e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000934f30, {0x2695640?, 0xc000661500?}, 0xc0009cb0c0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/grpc_provider.go:661 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ReadResource(0x2695598?, {0x2695640?, 0xc0006611d0?}, 0xc0009cb0c0)
github.com/hashicorp/terraform-plugin-mux@v0.12.0/tf5muxserver/mux_server_ReadResource.go:35 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0008df900, {0x2695640?, 0xc000660750?}, 0xc00085efc0)
github.com/hashicorp/terraform-plugin-go@v0.19.1/tfprotov5/tf5server/server.go:789 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x205b5c0?, 0xc0008df900}, {0x2695640, 0xc000660750}, 0xc000ac6780, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:431 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000848000, {0x2695640, 0xc0006606c0}, {0x269d8e0, 0xc000582b60}, 0xc001115b00, 0xc0008a5b00, 0x3674fc8, 0x0)
google.golang.org/grpc@v1.59.0/server.go:1343 +0xe49
google.golang.org/grpc.(*Server).handleStream(0xc000848000, {0x269d8e0, 0xc000582b60}, 0xc001115b00)
google.golang.org/grpc@v1.59.0/server.go:1737 +0xca6
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.59.0/server.go:986 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.59.0/server.go:997 +0x15c

Error: The terraform-provider-linode_v2.10.0 plugin crashed!

Expected Behavior

Plan or apply should reboot instance into selected config, or perhaps some form of warning/caught error?

Actual Behavior

Provider plugin crash.

Steps to Reproduce

  1. Reboot instance into recovery mode via console.
  2. Try to run terraform plan.

@devotoare Thanks for the report!

As far as I can tell this panic is the result of the lack of graceful handling for a null secondary entity ID in this bit of logic.

I've created a ticket in our internal tracker to resolve this and will let you know as soon as we have any updates.