ClickHouse / terraform-provider-clickhouse

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

Unable to use the provider to manage `dev` instances of Clickhouse after upgrading to provider version `1.2.4`, `num_replicas` not supported on `dev` instances #184

Closed jamiezieziula closed 2 weeks ago

jamiezieziula commented 3 weeks ago

After upgrading to provider version 1.2.4, trying to apply terraform fails with the following error:

Error: Error Updating ClickHouse Service Scaling
with clickhouse_service.events
on clickhouse.tf line 42, in resource "clickhouse_service" "events":
resource "clickhouse_service" "events" {
Could not update service scaling, unexpected error: status: 400, body: {"requestId":"2b03ac68-e70b-4eb7-a0c5-4e6c54476de8","error":"BAD_REQUEST: request body.numReplicas: Number of replicas must be greater than 3 <number:0>","status":400}

As documented in the provider, num_replicas is only support on production instances. However, even when omitting the num_replicas configuration altogether, or passing null as the value, the provider still attempts to reconcile it.

nikita-vanyasin commented 3 weeks ago

Hi @jamiezieziula Thanks for the report! We will take a look and keep you updated 👌🏻

whites11 commented 3 weeks ago

hello @jamiezieziula and thanks for your report. I tried replicating this by creating a new development tier service and I could not. I assume the service you're witnessing this error on existed before 1.2.4 and the issue started only after the upgrade.

I also tried creating a dev service using version 1.2.3 and then upgrading to 1.2.4, still with no error.

Would it be possible to share the .tfstate file's content? we only need the num_replicas field of the service resource. Example:

"resources": [
    {
      "mode": "managed",
      "type": "clickhouse_service",
      "name": "service",
      "provider": "provider[\"registry.terraform.io/clickhouse/clickhouse\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            ...
            "num_replicas": null,
           ...
mjroeleveld commented 3 weeks ago

I'm also getting this error

whites11 commented 3 weeks ago

I'm also getting this error

same question for you then, can you please provide the details I requested above?

mjroeleveld commented 3 weeks ago

@whites11 num_replicas is null because it complains that you cannot provide it for development.

With num_replicas

Screenshot 2024-11-04 at 16 26 24

Without num_replicas

Screenshot 2024-11-04 at 16 26 36
jamiezieziula commented 3 weeks ago

@whites11 - state file below:

    {
      "mode": "managed",
      "type": "clickhouse_service",
      "name": "events",
      "provider": "provider[\"registry.terraform.io/clickhouse/clickhouse\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
           ...
            "name": "events-dev",
            "num_replicas": null,
            "tier": "development"
          },
jamiezieziula commented 3 weeks ago

As @mjroeleveld mentioned, it fails whether num_replicas is specified or not. We upgraded from provider version 0.0.4 to the latest 1.2.4. FWIW, the production services we mange via terraform (unsurprisingly) apply with no issue.

whites11 commented 3 weeks ago

I was able to replicate this.

smstone commented 2 weeks ago

Hello, we pushed a fix to address this issue: https://github.com/ClickHouse/terraform-provider-clickhouse/releases/tag/v1.2.5 Please try this out and re-open if you have any issues. Thank you!