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

Unable to read interface resource. #338

Open
BegBlev opened this issue Feb 8, 2023 · 1 comment
Open

Unable to read interface resource. #338

BegBlev opened this issue Feb 8, 2023 · 1 comment

Comments

@BegBlev
Copy link
Contributor

BegBlev commented Feb 8, 2023

Hello,

When a device interface is connected, read this interface breaks the provider.

If I create 2 devices with 1 interface each and, if I terraform apply -target=netbox_device_interface.interface1 it works.
If I then connect the interfaces together and if I terraform apply -target=netbox_device_interface.interface1 it breaks the provider.

Versions

  • Terraform: v1.3.6
  • Netbox provider: v3.0.13

Affected Resource(s)

  • netbox_device_interface

Steps to Reproduce

Create 2 devices with 1 interface each.

resource "netbox_manufacturer" "test" {
  name = "test"
}

resource "netbox_device_type" "test" {
  model = "test"
  manufacturer_id = netbox_manufacturer.test.id
}

resource "netbox_site" "test" {
  name = "test"
}

resource "netbox_device_role" "test" {
  color_hex = "000000"
  name      = "test"
}

resource "netbox_device" "test1" {
  name = "test1"
  device_type_id = netbox_device_type.test.id
  role_id = netbox_device_role.test.id
  site_id = netbox_site.test.id
}

resource "netbox_device_interface" "interface1" {
  device_id = netbox_device.test1.id
  name = "test"
  type = "1000base-t"
}

resource "netbox_device" "test2" {
  name = "test2"
  device_type_id = netbox_device_type.test.id
  role_id = netbox_device_role.test.id
  site_id = netbox_site.test.id
}

resource "netbox_device_interface" "interface2" {
  device_id = netbox_device.test2.id
  name = "test"
  type = "1000base-t"
}

Then, force a netbox_device_interface read:

terraform apply -target=modules.netbox_content.netbox_device_interface.interface1
module.netbox_content.netbox_device_role.test: Refreshing state... [id=16]
module.netbox_content.netbox_site.test: Refreshing state... [id=10]
module.netbox_content.netbox_manufacturer.test: Refreshing state... [id=25]
module.netbox_content.netbox_device_type.test: Refreshing state... [id=117]
module.netbox_content.netbox_device.test1: Refreshing state... [id=1855]
module.netbox_content.netbox_device_interface.interface1: Refreshing state... [id=32347]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an
│ error message.
╵
╷
│ Warning: Applied changes may be incomplete
│ 
│ The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be fully updated. Run the following command
│ to verify that no other changes are pending:
│     terraform plan
│ 	
│ Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use
│ it as part of an error message.
╵
Releasing state lock. This may take a few moments...

Then, if I connect those interfaces together.
image
and I read back the device interface:

terraform apply -target=module.netbox_content.netbox_device_interface.interface1
module.netbox_content.netbox_manufacturer.test: Refreshing state... [id=25]
module.netbox_content.netbox_site.test: Refreshing state... [id=10]
module.netbox_content.netbox_device_role.test: Refreshing state... [id=16]
module.netbox_content.netbox_device_type.test: Refreshing state... [id=117]
module.netbox_content.netbox_device.test1: Refreshing state... [id=1855]
module.netbox_content.netbox_device_interface.interface1: Refreshing state... [id=32347]
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an
│ error message.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.netbox_content.netbox_device_interface.interface1,
│   on .terraform/modules/netbox_content/bug.tf line 26, in resource "netbox_device_interface" "interface1":
│   26: resource "netbox_device_interface" "interface1" {
│ 
│ 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.0.13 plugin:

panic: interface conversion: error is *json.UnmarshalTypeError, not *dcim.DcimInterfacesReadDefault

goroutine 95 [running]:
github.com/e-breuninger/terraform-provider-netbox/netbox.resourceNetboxDeviceInterfaceRead({0x1b5c7e0?, 0xc00035fda0?}, 0xc000675500, {0x164eea0?, 0xc0004d72c0})
	github.com/e-breuninger/terraform-provider-netbox/netbox/resource_netbox_device_interface.go:150 +0x3ec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc00010f0a0, {0x1b5c7e0, 0xc00035fda0}, 0xd?, {0x164eea0, 0xc0004d72c0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00010f0a0, {0x1b5c7e0, 0xc00035fda0}, 0xc000435380, {0x164eea0, 0xc0004d72c0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000185848, {0x1b5c7e0?, 0xc00035fc80?}, 0xc00041fc80)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000238820, {0x1b5c7e0?, 0xc00035f6b0?}, 0xc00066ce40)
	github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x188b5a0?, 0xc000238820}, {0x1b5c7e0, 0xc00035f6b0}, 0xc000127c00, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000210000, {0x1b60580, 0xc0002931e0}, 0xc000391e60, 0xc0002906c0, 0x2a2eaf0, 0x0)
	google.golang.org/grpc@v1.51.0/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc000210000, {0x1b60580, 0xc0002931e0}, 0xc000391e60, 0x0)
	google.golang.org/grpc@v1.51.0/server.go:1713 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.51.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.51.0/server.go:963 +0x28a

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

... it breaks the plugin.

@BegBlev
Copy link
Contributor Author

BegBlev commented Mar 23, 2023

Unfortunatly #341 did not solve the issue.

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