ClickHouse / terraform-provider-clickhouse

Terraform Provider for ClickHouse Cloud
Apache License 2.0
23 stars 8 forks source link

provider produced an unexpected new value: .num_replicas: was null, but now cty.NumberIntVal(3) #178

Closed tstraley closed 1 month ago

tstraley commented 1 month ago

Just started experiencing this this morning without making any changes to our Clickhouse resources:

module.clickhouse.clickhouse_service.main: Modifying... [id=29c6f52d-e036-4c46-a975-569f2f52a7b5]
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to module.clickhouse.clickhouse_service.main,
│ provider "provider[\"registry.terraform.io/clickhouse/clickhouse\"]"
│ produced an unexpected new value: .num_replicas: was null, but now
│ cty.NumberIntVal(3).
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

Previously, our plans and applies were treating num_replicas as optional per the docs and left null. We had many terraform applies to change other resources that were fine.

Then this morning, the plans now show a diff with our Clickhouse service:

  # module.clickhouse.clickhouse_service.main will be updated in-place
  ~ resource "clickhouse_service" "main" {
      ~ backup_configuration    = {
          ~ backup_period_in_hours           = 24 -> (known after apply)
          ~ backup_retention_period_in_hours = 24 -> (known after apply)
          + backup_start_time                = (known after apply)
        } -> (known after apply)
        id                      = "29c6f52d-e036-4c46-a975-569f2f52a7b5"
        name                    = "exp0-us-east-1-N1-clickhouse"
      - num_replicas            = 3 -> null
        # (12 unchanged attributes hidden)
    }

And apply leads to the failure above indicating a bug in this provider.

clawrence121 commented 1 month ago

I am seeing the same behaviour in Terraform Cloud using provider version 1.2.3:

CleanShot 2024-10-22 at 07 49 27@2x CleanShot 2024-10-22 at 07 49 37@2x

clawrence121 commented 1 month ago

I was able to resolve by manually setting replicas to 3:

CleanShot 2024-10-22 at 07 56 16@2x

yardenws commented 1 month ago

Hey, Happened on our side as well. Was able to fix this by adding num_replicas = 3 as well.

I'll just say, this is bigger than we think, Since the service is being updated, the data source that reads the private endpoint id is being updated as well.

and therefore, the vpc endpoints are being totally replaced..

Thanks for finding this fix @clawrence121 !

whites11 commented 1 month ago

Thank you all for your pointers.

This error started happening about 3 days ago, without any new release (latest test passing, first test failing )

I suspect a change in the API made this happen.

whites11 commented 1 month ago

Release 1.2.4 is out with a fix for this issue. Not mandatory, but you should be able to remove the num_replicas: 3 field you added after upgrading to this one. Thank you all for your help.