Skip to content

Commit cdf1faf

Browse files
authored
fix: Support configuration modification when active/standby switchove… (#2516)
* fix: Support configuration modification when active/standby switchover occurs * feat: add 2516 changelog
1 parent 1526083 commit cdf1faf

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.changelog/2516.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_mysql_instance: Support configuration modification when active/standby switchover occurs.
3+
```

tencentcloud/services/cdb/resource_tc_mysql_instance.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,12 +1083,25 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
10831083
deviceType = v.(string)
10841084
}
10851085

1086-
if v, ok := d.GetOk("first_slave_zone"); ok {
1087-
firstSlaveZone = v.(string)
1088-
}
1086+
if d.HasChange("first_slave_zone") || d.HasChange("second_slave_zone") {
1087+
if v, ok := d.GetOk("first_slave_zone"); ok {
1088+
firstSlaveZone = v.(string)
1089+
}
10891090

1090-
if v, ok := d.GetOk("second_slave_zone"); ok {
1091-
secondSlaveZone = v.(string)
1091+
if v, ok := d.GetOk("second_slave_zone"); ok {
1092+
secondSlaveZone = v.(string)
1093+
}
1094+
} else {
1095+
mysqlInfo, e := tencentMsyqlBasicInfoRead(ctx, d, meta, true)
1096+
if e != nil {
1097+
return e
1098+
}
1099+
if mysqlInfo != nil && mysqlInfo.SlaveInfo != nil && mysqlInfo.SlaveInfo.First != nil && mysqlInfo.SlaveInfo.First.Zone != nil {
1100+
firstSlaveZone = *mysqlInfo.SlaveInfo.First.Zone
1101+
}
1102+
if mysqlInfo != nil && mysqlInfo.SlaveInfo != nil && mysqlInfo.SlaveInfo.Second != nil && mysqlInfo.SlaveInfo.Second.Zone != nil {
1103+
firstSlaveZone = *mysqlInfo.SlaveInfo.Second.Zone
1104+
}
10921105
}
10931106

10941107
if v, ok := d.GetOkExists("wait_switch"); ok {

tencentcloud/services/cdb/resource_tc_mysql_instance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ resource "tencentcloud_mysql_instance" "mysql8" {
642642
mem_size = 1000
643643
volume_size = 25
644644
intranet_port = 3306
645-
security_groups = ["sg-3k7vtgf7"]
645+
security_groups = ["sg-05f7wnhn"]
646646
647647
tags = {
648648
createdBy = "terraform"

0 commit comments

Comments
 (0)