yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
198 stars 109 forks source link

yandex_mdb_redis_cluster doesn't update host's replica_priority #387

Open alxrem opened 8 months ago

alxrem commented 8 months ago

Hello.

We have MDB Redis cluster configured like

resource "yandex_mdb_redis_cluster" "default" {
  name                = "default"
  environment         = "PRODUCTION"
  # . . .
  sharded             = false
  # . . .

  config {
    password = random_password.default.result
    version  = "6.2"
  }

  host {
    zone      = "ru-central1-a"
    subnet_id = yandex_vpc_subnet.a.id
  }

  host {
    zone      = "ru-central1-b"
    subnet_id = yandex_vpc_subnet.b.id
  }

  host {
    zone      = "ru-central1-c"
    subnet_id = yandex_vpc_subnet.c.id
  }
}

We encountered case when API returns no replica_priority for one of redis cluster replicas.

Response of yc managed-redis hosts list --format=json looks like

[
  {
    "name": "rc1a-HKXLgriTP9ueZvKE.mdb.yandexcloud.net",
    . . .
    "role": "REPLICA",
    "replica_priority": "100"
  },
  {
    "name": "rc1a-srXxSB1E6aiPtjld.mdb.yandexcloud.net",
    . . .
    "role": "REPLICA"
  },
  {
    "name": "rc1c-gHgs76OcqjcviHhJ.mdb.yandexcloud.net",
    . . .
    "role": "MASTER",
    "replica_priority": "100"
  }
]

In this case every run of terraform apply show plan

 ~ host {
          ~ replica_priority = 0 -> 100
            # (5 unchanged attributes hidden)
        }

but does nothing.

After manual setting of priority by

yc managed-redis hosts update ... --replica-priority 100

all hosts contain "replica_priority": "100" in properties and the plan shows no changes, as expected.

Could you fix provider to update replica_priority in case when API doesn't include priority in host properties.

alxrem commented 8 months ago

Seems like getHostUpdateInfo rejects priority update due to condition oldPriority != nil at

https://github.com/yandex-cloud/terraform-provider-yandex/blob/def27527f3e05424a4433dd1a4f1a50e0e7a44e2/yandex/resource_yandex_mdb_redis_cluster.go#L901-L906

KoDA82 commented 7 months ago

Hi, sorry for the delay in processing. Is this issue still relevant?

alxrem commented 7 months ago

We are not affected for this time. We fixed all clusters that were not returning replica_priority using the CLI. It is not possible to reproduce the creation of a node without replica_priority. The provider code has not been changed, so we assume that the error will be reproduced if the cloud for some reason does not return the replica_priority of the node again.