cockroachdb / terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Apache License 2.0
57 stars 12 forks source link

Provider produced inconsistent result after apply #113

Closed uLan08 closed 1 year ago

uLan08 commented 1 year ago

Received an error after applying, although the cluster itself was actually created.

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.cockroachdb_dedicated.cockroach_cluster.cluster, provider "provider[\"registry.terraform.io/cockroachdb/cockroach\"]" produced an
│ unexpected new value: .regions[0].primary: was cty.True, but now cty.False.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Running a plan after this forced a recreation of the cluster


Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.cockroachdb_dedicated.cockroach_cluster.cluster is tainted, so must be replaced

Terraform code

resource "cockroach_cluster" "cluster" {
  cloud_provider = "AWS"
  name           = "test"
  regions = [
    {
      name       = "ap-southeast-1"
      node_count = 3
      primary = true
    }
  ]

  dedicated = {
    num_virtual_cpus           = 2
    storage_gib                = 100
    private_network_visibility = true
  }

}

Terraform versions

Terraform v1.3.7
on darwin_amd64
+ provider registry.terraform.io/cockroachdb/cockroach v0.4.7
+ provider registry.terraform.io/hashicorp/aws v4.66.1
erademacher commented 1 year ago

Thanks for reporting this, @uLan08! To get you unblocked, you can remove the "primary = true" line for that region (primary regions actually only apply to serverless clusters) and run terraform untaint cockroach_cluster.cluster to avoid replacing the cluster.

@pjtatlow would you mind taking a look at this? It looks like if you try to specify a primary region for a dedicated cluster, it's ignored and the state doesn't match the plan, resulting in this error. We should probably return an error if a user tries to mark a dedicated region as primary and make sure the serverless restriction is well documented.

uLan08 commented 1 year ago

Thanks @erademacher, I did manage to unblock myself. Didn't know that primary regions only apply to serverless cluster, would be great if the plan already reflected this restriction and having this defined in the documentation as well.

pjtatlow commented 1 year ago

Sorry I missed this for so long! @erademacher let me know if you have any ideas for a better docs message.