e-breuninger / terraform-provider-netbox

Terraform provider to interact with Netbox
https://registry.terraform.io/providers/e-breuninger/netbox/latest/docs
Mozilla Public License 2.0
178 stars 130 forks source link

Plugin did not respond crash #359

Open tFable opened 1 year ago

tFable commented 1 year ago

Issue Reporting Guide

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v1.4.0
on darwin_arm64
+ provider registry.terraform.io/e-breuninger/netbox v3.1.0

Panic Output

│ Error: Plugin did not respond
│ 
│   with netbox_device_interface.bmc_if["30567"],
│   on servers.tf line 24, in resource "netbox_device_interface" "bmc_if":
│   24: resource "netbox_device_interface" "bmc_if" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-netbox_v3.1.0 plugin:

panic: interface conversion: error is *url.Error, not *dcim.DcimInterfacesReadDefault

goroutine 497 [running]:
github.com/e-breuninger/terraform-provider-netbox/netbox.resourceNetboxDeviceInterfaceRead({0x104457aa0?, 0x1400024f860?}, 0x140006f1300, {0x1041420e0?, 0x1400062ce60})
        github.com/e-breuninger/terraform-provider-netbox/netbox/resource_netbox_device_interface.go:150 +0x364
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x1400019d180, {0x104457aa0, 0x1400024f860}, 0xd?, {0x1041420e0, 0x1400062ce60})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:724 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x1400019d180, {0x104457aa0, 0x1400024f860}, 0x1400089e0d0, {0x1041420e0, 0x1400062ce60})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:1015 +0x468
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x140002139e0, {0x104457aa0?, 0x1400024f740?}, 0x140005c9500)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:613 +0x400
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x1400062c460, {0x104457aa0?, 0x1400024ef90?}, 0x140008903c0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x3e8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x10437f1c0?, 0x1400062c460}, {0x104457aa0, 0x1400024ef90}, 0x14000207dc0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400022a000, {0x10445b800, 0x140005809c0}, 0x1400052dc20, 0x14000117e30, 0x1052f3bd0, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1340 +0xb7c
google.golang.org/grpc.(*Server).handleStream(0x1400022a000, {0x10445b800, 0x140005809c0}, 0x1400052dc20, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1713 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.51.0/server.go:965 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.51.0/server.go:963 +0x290

Error: The terraform-provider-netbox_v3.1.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.

Expected Behavior

No plugin crash

Actual Behavior

Plug in crash

Steps to Reproduce

I haven't found a way to consistently reproduce but it does seem to have happened after the number of resources in the module grew a bit (currently at 166)

mdepedrof commented 4 months ago

I have the same error. I always get this error when use the resource "netbox_available_ip_address".

Error: Plugin did not respond
│ 
│   with netbox_available_ip_address.ip-vpn["0"],
│   on _vpn.servers.tf line 14, in resource "netbox_available_ip_address" "ip-vpn":
│   14: resource "netbox_available_ip_address" "ip-vpn" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.

Any idea?

mdepedrof commented 4 months ago

Finally it can solve my problem. In my case I use netbox_available_ip_address to find the following IP inside a prefix but I used ip_range_id instead of prefix_id

resource "netbox_available_ip_address" "ip-database" {
  ip_range_id   = xxxx
  status      = "xxxx"
}

Just replace ip_range_id by the correct prefix_idand all works fine.

resource "netbox_available_ip_address" "ip-database" {
  prefix_id* = xxxx
  status      = "xxxx"
}

I found this by looking in my netbox logs and saw that the API was responding with 404 on some requests. After some research I found the error.