Client
Bigtable Admin
Code
From the Terraform Google provider:
First we create an instance without specifying KmsKeyName in the cluster: https://github.com/hashicorp/terraform-provider-google-beta/blob/master/google-beta/resource_bigtable_instance.go#L177
Then we attempt to read the instance clusters which causes the crash:
https://github.com/hashicorp/terraform-provider-google-beta/blob/master/google-beta/resource_bigtable_instance.go#L224
Expected behavior
List clusters without crashing.
Actual behavior
Panic when listing clusters:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x169c554]
goroutine 81 [running]:
cloud.google.com/go/bigtable.(*InstanceAdminClient).Clusters(0xc0012133c0, 0x479a918, 0xc00193b590, 0xc000bf08ea, 0x12, 0x0, 0x0, 0x0, 0x0, 0xc000721b00)
/Users/camthornton/go/pkg/mod/cloud.google.com/go/[email protected]/admin.go:1171 +0x494
github.com/hashicorp/terraform-provider-google-beta/google-beta.resourceBigtableInstanceRead(0xc001104800, 0x406b780, 0xc0011d2000, 0x0, 0x0)
/Users/camthornton/go/src/github.com/terraform-providers/terraform-provider-google-beta/google-beta/resource_bigtable_instance.go:224 +0x44c
github.com/hashicorp/terraform-provider-google-beta/google-beta.resourceBigtableInstanceCreate(0xc001104800, 0x406b780, 0xc0011d2000, 0x0, 0x0)
/Users/camthornton/go/src/github.com/terraform-providers/terraform-provider-google-beta/google-beta/resource_bigtable_instance.go:188 +0x6f0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000625b20, 0x479a8e0, 0xc001920400, 0xc001104800, 0x406b780, 0xc0011d2000, 0x0, 0x0, 0x0)
/Users/camthornton/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:318 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000625b20, 0x479a8e0, 0xc001920400, 0xc001216230, 0xc0010f2340, 0x406b780, 0xc0011d2000, 0x0, 0x0, 0x0, ...)
/Users/camthornton/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:456 +0x67b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00191a1f8, 0x479a8e0, 0xc001920400, 0xc000bc4550, 0xc001920400, 0x3faec80, 0xc000d3c200)
/Users/camthornton/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:955 +0x8ef
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc001052220, 0x479a988, 0xc001920400, 0xc001216000, 0xc001052220, 0xc000d3c210, 0xc00008aba0)
/Users/camthornton/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/server/server.go:332 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x3faec80, 0xc001052220, 0x479a988, 0xc000d3c210, 0xc000bfa060, 0x0, 0x479a988, 0xc000d3c210, 0xc000c261e0, 0x1c6)
/Users/camthornton/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000536c40, 0x47daed8, 0xc001872180, 0xc001924120, 0xc00191c750, 0x58fb6e0, 0x0, 0x0, 0x0)
/Users/camthornton/go/pkg/mod/google.golang.org/[email protected]/server.go:1217 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc000536c40, 0x47daed8, 0xc001872180, 0xc001924120, 0x0)
/Users/camthornton/go/pkg/mod/google.golang.org/[email protected]/server.go:1540 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000b37150, 0xc000536c40, 0x47daed8, 0xc001872180, 0xc001924120)
/Users/camthornton/go/pkg/mod/google.golang.org/[email protected]/server.go:878 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
/Users/camthornton/go/pkg/mod/google.golang.org/[email protected]/server.go:876 +0x1fd
Which is at this line: https://github.com/googleapis/google-cloud-go/blob/master/bigtable/admin.go#L1171
Additional context
Started after upgrading cloud.google.com/go/bigtable from v1.7.1 to v1.10.0.
Does not panic when specifying a KmsKeyName in the ClusterConfig with a non-empty value. Empty values also cause the panic.
Upgrading is necessary to add CMEK support to the Terraform Google Providers: https://github.com/GoogleCloudPlatform/magic-modules/pull/4770
Thanks for the report, we will get a fix out for this!
Thanks for raising this @c2thorn . The fix has been merged and will be included in the next release.
Most helpful comment
Thanks for raising this @c2thorn . The fix has been merged and will be included in the next release.