Skip to content

Commit ed06535

Browse files
authored
fix: modify config to support window period switch (#2472)
* fix: modify config to support window period switch * feat: add 2472 changelog * fix: modify mysql test * fix: modify mysql test
1 parent 3a5a453 commit ed06535

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

.changelog/2472.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: Modify configuration to support window period switching
3+
```

tencentcloud/services/cdb/resource_tc_mysql_instance.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
10161016
cpu := int64(d.Get("cpu").(int))
10171017
volumeSize := int64(d.Get("volume_size").(int))
10181018
deviceType := ""
1019+
var waitSwitch int64 = 0
10191020

10201021
fastUpgrade := int64(0)
10211022
if v, ok := d.GetOk("fast_upgrade"); ok {
@@ -1025,7 +1026,11 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
10251026
deviceType = v.(string)
10261027
}
10271028

1028-
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, -1, -1, "", "")
1029+
if v, ok := d.GetOkExists("wait_switch"); ok {
1030+
waitSwitch = int64(v.(int))
1031+
}
1032+
1033+
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, -1, -1, "", "", waitSwitch)
10291034

10301035
if err != nil {
10311036
return err
@@ -1069,6 +1074,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
10691074
deviceType := ""
10701075
firstSlaveZone := ""
10711076
secondSlaveZone := ""
1077+
var waitSwitch int64 = 0
10721078

10731079
fastUpgrade := int64(0)
10741080
if v, ok := d.GetOk("fast_upgrade"); ok {
@@ -1086,7 +1092,11 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met
10861092
secondSlaveZone = v.(string)
10871093
}
10881094

1089-
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, slaveDeployMode, slaveSyncMode, firstSlaveZone, secondSlaveZone)
1095+
if v, ok := d.GetOkExists("wait_switch"); ok {
1096+
waitSwitch = int64(v.(int))
1097+
}
1098+
1099+
asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, slaveDeployMode, slaveSyncMode, firstSlaveZone, secondSlaveZone, waitSwitch)
10901100

10911101
if err != nil {
10921102
return err

tencentcloud/services/cdb/resource_tc_mysql_instance_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func TestAccTencentCloudMysqlInstanceResource_prepaid(t *testing.T) {
123123
ResourceName: "tencentcloud_mysql_instance.prepaid",
124124
ImportState: true,
125125
ImportStateVerify: true,
126-
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "force_delete", "param_template_id", "fast_upgrade"},
126+
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "force_delete", "param_template_id", "fast_upgrade", "parameters"},
127127
},
128128
},
129129
})
@@ -148,7 +148,7 @@ func TestAccTencentCloudMysqlInstanceResource_DeviceType(t *testing.T) {
148148
ResourceName: "tencentcloud_mysql_instance.mysql_exclusive",
149149
ImportState: true,
150150
ImportStateVerify: true,
151-
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "force_delete", "param_template_id", "fast_upgrade"},
151+
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "force_delete", "param_template_id", "fast_upgrade", "parameters"},
152152
},
153153
{
154154
Config: testAccMySQLDeviceTypeUpdate,
@@ -228,7 +228,7 @@ func TestAccTencentCloudMysqlInstanceResource_MasterInstance_basic_and_update(t
228228
ResourceName: "tencentcloud_mysql_instance.mysql_master",
229229
ImportState: true,
230230
ImportStateVerify: true,
231-
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "first_slave_zone", "force_delete"},
231+
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "first_slave_zone", "force_delete", "parameters"},
232232
},
233233
// add tag
234234
{
@@ -430,7 +430,7 @@ resource "tencentcloud_mysql_instance" "prepaid" {
430430

431431
const testAccMySQLDeviceType = `
432432
variable "temporary_param_tmpl_id" {
433-
default = 19656
433+
default = 21117
434434
}
435435
436436
resource "tencentcloud_mysql_instance" "mysql_exclusive" {
@@ -452,7 +452,7 @@ resource "tencentcloud_mysql_instance" "mysql_exclusive" {
452452

453453
const testAccMySQLDeviceTypeUpdate = `
454454
variable "temporary_param_tmpl_id" {
455-
default = 19656
455+
default = 21117
456456
}
457457
458458
resource "tencentcloud_mysql_instance" "mysql_exclusive" {
@@ -624,7 +624,7 @@ resource "tencentcloud_mysql_instance" "mysql8" {
624624
mem_size = 1000
625625
volume_size = 25
626626
intranet_port = 3306
627-
security_groups = ["sg-ngx2bo7j"]
627+
security_groups = ["sg-3k7vtgf7"]
628628
629629
tags = {
630630
createdBy = "terraform"

tencentcloud/services/cdb/service_tencentcloud_mysql.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,12 +1217,10 @@ func (me *MysqlService) ModifyDBInstanceVipVport(ctx context.Context, mysqlId, v
12171217

12181218
func (me *MysqlService) UpgradeDBInstance(ctx context.Context, mysqlId string,
12191219
memSize, cpu, volumeSize, fastUpgrade int64, deviceType string, slaveDeployMode, slaveSyncMode int64,
1220-
firstSlaveZone, secondSlaveZone string) (asyncRequestId string, errRet error) {
1220+
firstSlaveZone, secondSlaveZone string, waitSwitch int64) (asyncRequestId string, errRet error) {
12211221

12221222
logId := tccommon.GetLogId(ctx)
12231223

1224-
var waitSwitch int64 = 0 // 0- switch immediately, 1- time window switch
1225-
12261224
request := cdb.NewUpgradeDBInstanceRequest()
12271225
request.InstanceId = &mysqlId
12281226
request.Memory = &memSize

0 commit comments

Comments
 (0)