Skip to content

Commit

Permalink
fix: Support configuration modification when active/standby switchove… (
Browse files Browse the repository at this point in the history
#2516)

* fix: Support configuration modification when active/standby switchover occurs

* feat: add 2516 changelog
  • Loading branch information
gitmkn authored Feb 5, 2024
1 parent 1526083 commit cdf1faf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/2516.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_mysql_instance: Support configuration modification when active/standby switchover occurs.
```
23 changes: 18 additions & 5 deletions tencentcloud/services/cdb/resource_tc_mysql_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,12 +1083,25 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
deviceType = v.(string)
}

if v, ok := d.GetOk("first_slave_zone"); ok {
firstSlaveZone = v.(string)
}
if d.HasChange("first_slave_zone") || d.HasChange("second_slave_zone") {
if v, ok := d.GetOk("first_slave_zone"); ok {
firstSlaveZone = v.(string)
}

if v, ok := d.GetOk("second_slave_zone"); ok {
secondSlaveZone = v.(string)
if v, ok := d.GetOk("second_slave_zone"); ok {
secondSlaveZone = v.(string)
}
} else {
mysqlInfo, e := tencentMsyqlBasicInfoRead(ctx, d, meta, true)
if e != nil {
return e
}
if mysqlInfo != nil && mysqlInfo.SlaveInfo != nil && mysqlInfo.SlaveInfo.First != nil && mysqlInfo.SlaveInfo.First.Zone != nil {
firstSlaveZone = *mysqlInfo.SlaveInfo.First.Zone
}
if mysqlInfo != nil && mysqlInfo.SlaveInfo != nil && mysqlInfo.SlaveInfo.Second != nil && mysqlInfo.SlaveInfo.Second.Zone != nil {
firstSlaveZone = *mysqlInfo.SlaveInfo.Second.Zone
}
}

if v, ok := d.GetOkExists("wait_switch"); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ resource "tencentcloud_mysql_instance" "mysql8" {
mem_size = 1000
volume_size = 25
intranet_port = 3306
security_groups = ["sg-3k7vtgf7"]
security_groups = ["sg-05f7wnhn"]
tags = {
createdBy = "terraform"
Expand Down

0 comments on commit cdf1faf

Please sign in to comment.