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

terraform import 時に panic #1015

Open
saza-ku opened this issue Jan 29, 2023 · 2 comments
Open

terraform import 時に panic #1015

saza-ku opened this issue Jan 29, 2023 · 2 comments

Comments

@saza-ku
Copy link

saza-ku commented Jan 29, 2023

terraform import を用いて既存のリソースを取得しようとしたときに、以下のようなエラーが発生しました。

terraform import sakuracloud_server.foo bar
sakuracloud_server.foo: Importing from ID "bar"...
sakuracloud_server.foo: Import prepared!
  Prepared sakuracloud_server for import
sakuracloud_server.foo: Refreshing state... [id=bar]
╷
│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.
╵


Stack trace from the terraform-provider-sakuracloud_v2.22.0 plugin:

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

goroutine 82 [running]:
github.com/sacloud/terraform-provider-sakuracloud/sakuracloud.resourceSakuraCloudServerRead({0x1330468, 0xc0005ecc00}, 0xc000b08080, {0xfe4720?, 0xc0005ec480?})
	/home/runner/work/terraform-provider-sakuracloud/terraform-provider-sakuracloud/sakuracloud/resource_sakuracloud_server.go:340 +0x33a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc00056e000, {0x13304a0, 0xc000a77830}, 0xd?, {0xfe4720, 0xc0005ec480})
	/home/runner/go/pkg/mod/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(0xc00056e000, {0x13304a0, 0xc000a77830}, 0xc000a73110, {0xfe4720, 0xc0005ec480})
	/home/runner/go/pkg/mod/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(0xc00011dc98, {0x13304a0?, 0xc000a77710?}, 0xc000a40f80)
	/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ReadResource({0xc000520d20, 0xc000520d80, {0xc0007c5be0, 0x1, 0x1}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tf5muxserver/mux_server_ReadResource.go:26 +0x102
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ReadResource({0xc0007e5890, 0xc0007e58f0, {0xc0007c5d30, 0x1, 0x1}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tf5muxserver/mux_server_ReadResource.go:26 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0002b2000, {0x13304a0?, 0xc000a76ab0?}, 0xc0005ec900)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x111e2c0?, 0xc0002b2000}, {0x13304a0, 0xc000a76ab0}, 0xc000564850, 0x0)
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000894000, {0x1336c00, 0xc000908340}, 0xc000a7ab40, 0xc0001f7c80, 0x1ad0970, 0x0)
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc000894000, {0x1336c00, 0xc000908340}, 0xc000a7ab40, 0x0)
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1713 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-sakuracloud_v2.22.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.

環境

  • OS: Manjaro Linux x86_64
  • Kernel: 5.15.85-1-MANJARO
  • Terraform version: v1.3.7
  • sakuracloud provider version: v2.22.0
@saza-ku
Copy link
Author

saza-ku commented Jan 29, 2023

引数で指定した ID が間違っていたため、それを直すと import に成功しました。

おそらく、ID のフォーマットに反した入力に対して panic を起こすと考えられます。

@yamamoto-febc
Copy link
Member

ご報告ありがとうございます!調査&対応します。

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

2 participants