From c5e2f697e13a3daf12b46a9015bd285722aa4a58 Mon Sep 17 00:00:00 2001 From: Arunma <41282634+gitmkn@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:04:39 +0800 Subject: [PATCH] fix: modify slaveDeployMode (#2502) * fix: modify slaveDeployMode * feat: add changelog --- .changelog/2502.txt | 3 +++ tencentcloud/services/cdb/resource_tc_mysql_instance.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changelog/2502.txt diff --git a/.changelog/2502.txt b/.changelog/2502.txt new file mode 100644 index 0000000000..9c183c977a --- /dev/null +++ b/.changelog/2502.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_instance: Optimize the availability zone problem when modifying the configuration after active/standby switchover. +``` diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_instance.go index fa26613718..9da7393edf 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.go @@ -1068,7 +1068,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met memSize := int64(d.Get("mem_size").(int)) cpu := int64(d.Get("cpu").(int)) volumeSize := int64(d.Get("volume_size").(int)) - slaveDeployMode := int64(d.Get("slave_deploy_mode").(int)) + var slaveDeployMode int64 = -1 slaveSyncMode := int64(d.Get("slave_sync_mode").(int)) deviceType := "" firstSlaveZone := "" @@ -1095,6 +1095,12 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met waitSwitch = int64(v.(int)) } + if d.HasChange("slave_deploy_mode") { + if v, ok := d.GetOkExists("slave_deploy_mode"); ok { + slaveDeployMode = int64(v.(int)) + } + } + asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, slaveDeployMode, slaveSyncMode, firstSlaveZone, secondSlaveZone, waitSwitch) if err != nil {