cockroachdb / terraform-provider-cockroach

Terraform provider for CockroachDB Cloud
Apache License 2.0
55 stars 10 forks source link

Error when scaling down cluster #152

Closed uLan08 closed 11 months ago

uLan08 commented 11 months ago

Trying to scale down a cluster from a 4vCPU node to 2vCPU node but encountered an inconsistent apply error.

Terraform plan

  # module.crdb_foo.cockroach_cluster.cluster will be updated in-place
  ~ resource "cockroach_cluster" "cluster" {
      ~ dedicated         = {
          ~ disk_iops                  = 1500 -> (known after apply)
          ~ machine_type               = "m6i.xlarge" -> (known after apply)
          ~ memory_gib                 = 16 -> (known after apply)
          ~ num_virtual_cpus           = 4 -> 2
            # (2 unchanged attributes hidden)
        }
        id                = "<REDACTED>"
        name              = "foo-cluster"
      ~ operation_status  = "UNSPECIFIED" -> (known after apply)
      ~ regions           = [
          ~ {
                name       = "<REDACTED>"
              ~ sql_dns    = "<REDACTED>" -> (known after apply)
              ~ ui_dns     = "<REDACTED>" -> (known after apply)
                # (2 unchanged attributes hidden)
            },
        ]
      ~ state             = "CREATED" -> (known after apply)
      ~ upgrade_status    = "FINALIZED" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

Error

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.crdb_foo.cockroach_cluster.cluster, provider "provider[\"registry.terraform.io/cockroachdb/cockroach\"]" produced an unexpected new value: .dedicated.num_virtual_cpus: was cty.NumberIntVal(2), but now cty.NumberIntVal(4).
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Versions

▶ terraform version
Terraform v1.3.7
on darwin_amd64
+ provider registry.terraform.io/cockroachdb/cockroach v0.4.7

Had to manually apply the changes via the CockroachDB console.

erademacher commented 11 months ago

Hi Patrick. Thanks for reporting this! I'm able to reproduce locally and should be able to get a fix into the next release.

erademacher commented 11 months ago

This should be fixed in v1.0.0. Please let me know if the issue persists.