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

Plugin did not respond - rediscloud_subscription interface {} is nil not string #484

Closed cameron-mills closed 3 weeks ago

cameron-mills commented 4 months ago

Hi Folks,

I previously ran a successful apply with this terraform - I ran a terraform destroy and have been getting an error trying to reapply ever since.

I've tried version bumping the providers (this started on 1.5.0) and the usual reinitialising etc.

Terraform Version

$ terraform -v                                                                                                                                                  
Terraform v1.7.0
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.84.0
+ provider registry.terraform.io/hashicorp/google-beta v5.25.0
+ provider registry.terraform.io/redislabs/rediscloud v1.6.0

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "rediscloud_subscription" "subscription" {

  name           = var.gcp_project_id
  payment_method = "marketplace"
  memory_storage = "ram"

  allowlist {
    security_group_ids = [""]
    cidrs = [for _, subnet in data.google_compute_subnetwork.subnets : subnet.ip_cidr_range]
  }

  cloud_provider {
    provider = "GCP"
    region {
      region                     = var.gcp_region
      networking_deployment_cidr = var.deployment_cidr
    }
  }

  creation_plan {
    memory_limit_in_gb           = var.memory_limit_gb
    quantity                     = 1
    replication                  = true
    throughput_measurement_by    = "operations-per-second"
    throughput_measurement_value = var.throughput_ops
    modules                      = var.redis_modules
  }
}

Debug Output

024-04-16T11:43:08.190+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/google/4.84.0/darwin_arm64/terraform-provider-google_v4.84.0_x5 pid=19083
2024-04-16T11:43:08.190+0100 [DEBUG] provider: plugin exited
2024-04-16T11:43:08.197+0100 [WARN]  Provider "registry.terraform.io/redislabs/rediscloud" produced an invalid plan for rediscloud_subscription.subscription, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .cloud_provider[0].cloud_account_id: planned value cty.StringVal("1") for a non-computed attribute
      - .creation_plan[0].support_oss_cluster_api: planned value cty.False for a non-computed attribute
2024-04-16T11:43:08.199+0100 [INFO]  Starting apply for rediscloud_subscription.subscription
2024-04-16T11:43:08.200+0100 [DEBUG] rediscloud_subscription.subscription: applying the planned Create change
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.preferred_availability_zones" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.networks" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.networks" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.preferred_availability_zones" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.preferred_availability_zones" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.201+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: setting computed for "cloud_provider.0.region.0.networks" from ComputedKeys: timestamp="2024-04-16T11:43:08.201+0100"
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: panic: interface conversion: interface {} is nil, not string
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: goroutine 5 [running]:
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/RedisLabs/terraform-provider-rediscloud/provider.interfaceToStringSlice(...)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/RedisLabs/terraform-provider-rediscloud/provider/utils.go:30
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/RedisLabs/terraform-provider-rediscloud/provider.buildSubscriptionCreatePlanDatabases({0x1400012699a, 0x3}, 0x17d?)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/RedisLabs/terraform-provider-rediscloud/provider/resource_rediscloud_subscription.go:635 +0xd38
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/RedisLabs/terraform-provider-rediscloud/provider.resourceRedisCloudSubscriptionCreate({0x1054ef208, 0x140004e15c0}, 0x0?, {0x1053a7e20?, 0x1400000e1a0})
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/RedisLabs/terraform-provider-rediscloud/provider/resource_rediscloud_subscription.go:347 +0x1e4
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1400042c1c0, {0x1054ef240, 0x14000354420}, 0xd?, {0x1053a7e20, 0x1400000e1a0})
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:778 +0xe8
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400042c1c0, {0x1054ef240, 0x14000354420}, 0x14000279110, 0x140006a3f00, {0x1053a7e20, 0x1400000e1a0})
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:909 +0x890
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000401ed8, {0x1054ef240?, 0x14000354300?}, 0x1400026a8c0)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/grpc_provider.go:1027 +0xb70
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x1400043c1e0, {0x1054ef240?, 0x140000af860?}, 0x140001ac9a0)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x3b8
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1054b8060?, 0x1400043c1e0}, {0x1054ef240, 0x140000af860}, 0x140001ac930, 0x0)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: google.golang.org/grpc.(*Server).processUnaryRPC(0x140002501e0, {0x1054f2f00, 0x1400048a1a0}, 0x140003577a0, 0x1400043e2a0, 0x10599c800, 0x0)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     google.golang.org/grpc@v1.56.1/server.go:1337 +0xc64
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: google.golang.org/grpc.(*Server).handleStream(0x140002501e0, {0x1054f2f00, 0x1400048a1a0}, 0x140003577a0, 0x0)
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     google.golang.org/grpc@v1.56.1/server.go:1714 +0x82c
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: google.golang.org/grpc.(*Server).serveStreams.func1.1()
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     google.golang.org/grpc@v1.56.1/server.go:959 +0x84
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0: created by google.golang.org/grpc.(*Server).serveStreams.func1
2024-04-16T11:43:08.204+0100 [DEBUG] provider.terraform-provider-rediscloud_v1.6.0:     google.golang.org/grpc@v1.56.1/server.go:957 +0x16c
2024-04-16T11:43:08.205+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-04-16T11:43:08.205+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/redislabs/rediscloud/1.6.0/darwin_arm64/terraform-provider-rediscloud_v1.6.0 pid=19082 error="exit status 2"
2024-04-16T11:43:08.206+0100 [ERROR] plugin.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-04-16T11:43:08.206+0100 [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-04-16T11:43:08.206+0100 [ERROR] vertex "rediscloud_subscription.subscription" error: Plugin did not respond

Panic Output

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

panic: interface conversion: interface {} is nil, not string

goroutine 5 [running]:
github.com/RedisLabs/terraform-provider-rediscloud/provider.interfaceToStringSlice(...)
        github.com/RedisLabs/terraform-provider-rediscloud/provider/utils.go:30
github.com/RedisLabs/terraform-provider-rediscloud/provider.buildSubscriptionCreatePlanDatabases({0x1400012699a, 0x3}, 0x17d?)
        github.com/RedisLabs/terraform-provider-rediscloud/provider/resource_rediscloud_subscription.go:635 +0xd38
github.com/RedisLabs/terraform-provider-rediscloud/provider.resourceRedisCloudSubscriptionCreate({0x1054ef208, 0x140004e15c0}, 0x0?, {0x1053a7e20?, 0x1400000e1a0})
        github.com/RedisLabs/terraform-provider-rediscloud/provider/resource_rediscloud_subscription.go:347 +0x1e4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1400042c1c0, {0x1054ef240, 0x14000354420}, 0xd?, {0x1053a7e20, 0x1400000e1a0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:778 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400042c1c0, {0x1054ef240, 0x14000354420}, 0x14000279110, 0x140006a3f00, {0x1053a7e20, 0x1400000e1a0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/resource.go:909 +0x890
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000401ed8, {0x1054ef240?, 0x14000354300?}, 0x1400026a8c0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.28.0/helper/schema/grpc_provider.go:1027 +0xb70
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x1400043c1e0, {0x1054ef240?, 0x140000af860?}, 0x140001ac9a0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x3b8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1054b8060?, 0x1400043c1e0}, {0x1054ef240, 0x140000af860}, 0x140001ac930, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002501e0, {0x1054f2f00, 0x1400048a1a0}, 0x140003577a0, 0x1400043e2a0, 0x10599c800, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1337 +0xc64
google.golang.org/grpc.(*Server).handleStream(0x140002501e0, {0x1054f2f00, 0x1400048a1a0}, 0x140003577a0, 0x0)
        google.golang.org/grpc@v1.56.1/server.go:1714 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.1/server.go:959 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.1/server.go:957 +0x16c

Error: The terraform-provider-rediscloud_v1.6.0 plugin crashed!

Expected Behavior

A new subscription should be created in rediscloud

Actual Behavior

An error was received interface conversion: interface {} is nil, not string

Steps to Reproduce

  1. terragrunt apply

Important Factoids

Running via terragrunt;

$ terragrunt -v 
[INFO] Getting version from tgenv-version-name
[INFO] TGENV_VERSION is 0.53.8
terragrunt version v0.53.8
cameron-mills commented 4 months ago

Resolution While the subscription already existed - I changed the variable redis_modules being used to set the modules argument in the creation plan to have a default value of [""] - a list containing an empty string.

After following through the stacktrace I realised the provider was unable to handle this and attempted to update the redis_modules argument to have a default value of [] instead (an empty list) which solved the problem.

I'll attempt to add some error handling to this in the coming days to make things a little more graceful.

JohnSharpe commented 3 weeks ago

Hi @cameron-mills, looks like you've found the problem! Requesting a module named "" is/should be invalid but the error around it has been addressed. Please give 1.8.0 a spin if you need any other new features (please take a look at the changelog) and let us know if you run into any issues. Cheers!