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

Plugin crashes when importing top-level dataset #15

Open
Razaekel opened this issue Apr 26, 2023 · 3 comments
Open

Plugin crashes when importing top-level dataset #15

Razaekel opened this issue Apr 26, 2023 · 3 comments

Comments

@Razaekel
Copy link

Attempting to import the Top level dataset (System Dataset Pool) causes the plugin to crash with an 'out of bounds' error.

> terraform import truenas_dataset.main "main"

truenas_dataset.main: Importing from ID "main"...
truenas_dataset.main: Import prepared!
  Prepared truenas_dataset for import
truenas_dataset.main: Refreshing state... [id=main]
╷
│ Error: Plugin did not respond
│
│ 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-truenas_v0.11.1.exe plugin:

panic: runtime error: slice bounds out of range [1:0]

goroutine 30 [running]:
github.com/dariusbakunas/terraform-provider-truenas/truenas.newDatasetPath({0xc0002a7b78?, 0xc00007dce0?})
        github.com/dariusbakunas/terraform-provider-truenas/truenas/resource_truenas_dataset.go:40 +0x16a
github.com/dariusbakunas/terraform-provider-truenas/truenas.resourceTrueNASDatasetRead({0x19f7968, 0xc00007dce0}, 0xc0004d0c80, {0x180f0e0?, 0xc00007d620})
        github.com/dariusbakunas/terraform-provider-truenas/truenas/resource_truenas_dataset.go:311 +0x37c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000358380, {0x19f79a0, 0xc0003f57d0}, 0xd?, {0x180f0e0, 0xc00007d620})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000358380, {0x19f79a0, 0xc0003f57d0}, 0xc0002ad6c0, {0x180f0e0, 0xc00007d620})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00029f2a8, {0x19f79a0?, 0xc0003f56b0?}, 0xc000617100)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x497
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000300460, {0x19f79a0?, 0xc0003f4ed0?}, 0xc00007d9e0)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x49e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x188ca80?, 0xc000300460}, {0x19f79a0, 0xc0003f4ed0}, 0xc0001daa10, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000372000, {0x19fa560, 0xc00017b380}, 0xc00008efc0, 0xc000375050, 0x1edb4f0, 0x0)
        google.golang.org/[email protected]/server.go:1340 +0xd13
google.golang.org/grpc.(*Server).handleStream(0xc000372000, {0x19fa560, 0xc00017b380}, 0xc00008efc0, 0x0)
        google.golang.org/[email protected]/server.go:1713 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-truenas_v0.11.1.exe 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.
@yuqo2450
Copy link

yuqo2450 commented May 27, 2023

I can confirm this. I get the same error when trying to get the top-level dataset.
When adding a sub dataset it works flawless.
e.g.:

data "truenas_dataset" "test" {
  dataset_id = "Tank"
}

@yuqo2450
Copy link

Ok I think Iw as wrong. And maybe @Razaekel as well. It considered the pool to be the top-level dataset. WHat is obviously not correct.
The dataset ID is pool/dataset.

@ArdRay
Copy link

ArdRay commented Jun 11, 2023

Correct, top-level import or data query fails. A friendlier error description would be welcome.

Stack trace from the terraform-provider-truenas_v0.11.1 plugin:

panic: runtime error: slice bounds out of range [1:0]

goroutine 25 [running]:
github.com/dariusbakunas/terraform-provider-truenas/truenas.newDatasetPath({0x140000350c0?, 0x104992948?})
        github.com/dariusbakunas/terraform-provider-truenas/truenas/resource_truenas_dataset.go:40 +0x14c
github.com/dariusbakunas/terraform-provider-truenas/truenas.dataSourceTrueNASDatasetRead({0x104992948, 0x1400007e5a0}, 0x0?, {0x1048d4960?, 0x140004b46c0})
        github.com/dariusbakunas/terraform-provider-truenas/truenas/data_source_truenas_dataset.go:479 +0x310
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000448b60, {0x104992980, 0x140002325d0}, 0xd?, {0x1048d4960, 0x140004b46c0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0x14000448b60, {0x104992980, 0x140002325d0}, 0x14000537900, {0x1048d4960, 0x140004b46c0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:943 +0x118
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0x140000a7218, {0x104992980?, 0x14000232390?}, 0x1400007c6e0)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1179 +0x304
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0x140000fc460, {0x104992980?, 0x14000611d40?}, 0x14000116550)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:658 +0x36c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x104952780?, 0x140000fc460}, {0x104992980, 0x14000611d40}, 0x14000549880, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:421 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000464000, {0x104995500, 0x140004a8340}, 0x14000353680, 0x14000467020, 0x104e60770, 0x0)
        google.golang.org/[email protected]/server.go:1340 +0xb90
google.golang.org/grpc.(*Server).handleStream(0x14000464000, {0x104995500, 0x140004a8340}, 0x14000353680, 0x0)
        google.golang.org/[email protected]/server.go:1713 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x298

Error: The terraform-provider-truenas_v0.11.1 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

3 participants