Skip to content

Commit 57969e6

Browse files
authored
fix: fix availability_zone (#2401)
* fix: fix availability_zone * feat: add 2401 changelog
1 parent 9830b30 commit 57969e6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.changelog/2401.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: Fix the availability zone problem after active/standby switchover.
3+
```

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func resourceTencentCloudMysqlInstance() *schema.Resource {
318318
}
319319

320320
/*
321-
[master] and [dr] and [ro] all need set
321+
[master] and [dr] and [ro] all need set
322322
*/
323323
func mysqlAllInstanceRoleSet(ctx context.Context, requestInter interface{}, d *schema.ResourceData, meta interface{}) error {
324324
requestByMonth, okByMonth := requestInter.(*cdb.CreateDBInstanceRequest)
@@ -438,7 +438,7 @@ func mysqlAllInstanceRoleSet(ctx context.Context, requestInter interface{}, d *s
438438
}
439439

440440
/*
441-
[master] need set
441+
[master] need set
442442
*/
443443
func mysqlMasterInstanceRoleSet(ctx context.Context, requestInter interface{}, d *schema.ResourceData, meta interface{}) error {
444444
requestByMonth, okByMonth := requestInter.(*cdb.CreateDBInstanceRequest)
@@ -916,7 +916,6 @@ func resourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interfac
916916
log.Printf("[CRITAL]%s provider set caresParameters fail, reason:%s\n ", logId, e.Error())
917917
return resource.NonRetryableError(e)
918918
}
919-
_ = d.Set("availability_zone", mysqlInfo.Zone)
920919
return nil
921920
})
922921
if err != nil {
@@ -944,6 +943,10 @@ func resourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interfac
944943
if backConfig.Response.BackupConfig != nil && *backConfig.Response.BackupConfig.Zone != "" {
945944
_ = d.Set("second_slave_zone", *backConfig.Response.BackupConfig.Zone)
946945
}
946+
947+
if backConfig.Response.Zone != nil {
948+
_ = d.Set("availability_zone", *backConfig.Response.Zone)
949+
}
947950
return nil
948951
})
949952
if err != nil {
@@ -953,7 +956,7 @@ func resourceTencentCloudMysqlInstanceRead(d *schema.ResourceData, meta interfac
953956
}
954957

955958
/*
956-
[master] and [dr] and [ro] all need update
959+
[master] and [dr] and [ro] all need update
957960
*/
958961
func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}, isReadonly bool) error {
959962

@@ -1206,7 +1209,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
12061209
}
12071210

12081211
/*
1209-
[master] need set
1212+
[master] need set
12101213
*/
12111214
func mysqlMasterInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
12121215
logId := getLogId(ctx)

0 commit comments

Comments
 (0)