RedisLabs / terraform-provider-rediscloud

Terraform Redis Cloud Provider: Deploy, update, and manage Redis Cloud databases as code through HashiCorp Terraform
https://registry.terraform.io/providers/RedisLabs/rediscloud/latest
Apache License 2.0
30 stars 23 forks source link

Datasource rediscloud_database crashes for active-active databases #468

Closed atsui-bay1 closed 2 months ago

atsui-bay1 commented 7 months ago

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

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed. 1.3.6

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

data "rediscloud_database" "database" {
  subscription_id = 123
  name            = "my-db"
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

│ Error: Plugin did not respond
│ 
│   with data.rediscloud_database.database["test.vault"],
│   on redis.tf line 12, in data "rediscloud_database" "database":
│   12: data "rediscloud_database" "database" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-rediscloud_v1.5.0 plugin:

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

goroutine 31 [running]:
github.com/RedisLabs/terraform-provider-rediscloud/provider.dataSourceRedisCloudDatabaseRead({0x19df128, 0xc000480300}, 0x0?, {0x1765000?, 0xc000134788})
        github.com/RedisLabs/terraform-provider-rediscloud/provider/datasource_rediscloud_database.go:234 +0xa3c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0000a0460, {0x19df160, 0xc0000fcdb0}, 0xd?, {0x1765000, 0xc000134788})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:795 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0000a0460, {0x19df160, 0xc0000fcdb0}, 0xc0004de400, {0x1765000, 0xc000134788})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:1015 +0x150
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc000012048, {0x19df160?, 0xc0000fcc90?}, 0xc00030c060)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/grpc_provider.go:1204 +0x38f
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc0000034a0, {0x19df160?, 0xc0000fc2d0?}, 0xc0000980f0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:661 +0x403
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x1875460?, 0xc0000034a0}, {0x19df160, 0xc0000fc2d0}, 0xc0000a4000, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:458 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000456000, {0x19e2ee0, 0xc0000e24e0}, 0xc00015a7e0, 0xc000093c20, 0x1ea7930, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf0
google.golang.org/grpc.(*Server).handleStream(0xc000456000, {0x19e2ee0, 0xc0000e24e0}, 0xc00015a7e0, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1714 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.1/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.1/server.go:957 +0x18c

Expected Behavior

Datasource should return the requested database, or a new datasource needs to be created for active-active databases

Actual Behavior

What actually happened? Crash, due to ThroughputMeasurement.By not existing in the JSON response

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

NoamSternRedis commented 6 months ago

Hi @atsui-bay1, thank you for the feedback and detailed description. We are investigating it. It seems like, as you mentioned, the database data source doesn't support A.

We will work on this soon and fix it. I'll make sure to keep you posted once we have an ETA.

NoamSternRedis commented 2 months ago

Hi @atsui-bay1, we have fixed the issue in version 1.7, which has just been released today. We have new data sources for A-A database and subscription

Thank you for your feedback!

atsui-bay1 commented 3 weeks ago

Hi @NoamSternRedis, I finally got around to testing this and can confirm that they work and solve our problem, thank you!

It would be nice if the A-A subscription data source exposed the regions, and I've filed an issue for that (with an easy workaround, so this is a very minor request)