Skip to content

Commit

Permalink
fix(crs): [119900225] Processing the change from a single-AZ instance… (
Browse files Browse the repository at this point in the history
#2961)

* fix(crs): [119900225] Processing the change from a single-AZ instance to a multi-AZ instance

* fix: add changelog
  • Loading branch information
gitmkn authored Nov 22, 2024
1 parent 684674d commit 4373fd7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/2961.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_redis_instance: Processing the change from a single-AZ instance to a multi-AZ instance.
```
39 changes: 33 additions & 6 deletions tencentcloud/services/crs/resource_tc_redis_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,13 +1181,40 @@ func resourceRedisNodeSetModify(ctx context.Context, service *RedisService, d *s
ZoneId: helper.IntUint64(zoneId),
})
}
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
_, err := service.UpgradeInstance(ctx, d.Id(), memSize, shardNum, redisReplicaCount+len(adds), addNodes)
if err != nil {
return tccommon.RetryError(err, redis.FAILEDOPERATION_UNKNOWN)
if redisReplicaCount+len(adds) == 0 && len(adds) == 1 {
// Processing the change from a single-AZ instance to a multi-AZ instance
request := redis.NewModifyInstanceAvailabilityZonesRequest()
if v, ok := d.GetOkExists("wait_switch"); ok {
request.SwitchOption = helper.IntInt64(v.(int))
} else {
request.SwitchOption = helper.IntInt64(2)
}
return nil
})
request.InstanceId = &id
request.NodeSet = append(request.NodeSet,
&redis.RedisNodeInfo{
NodeType: helper.IntInt64(1),
ZoneId: helper.IntUint64(adds[0]),
},
&redis.RedisNodeInfo{
NodeType: helper.IntInt64(0),
ZoneId: helper.IntUint64(int(*info.ZoneId)),
})
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
_, err := service.client.UseRedisClient().ModifyInstanceAvailabilityZones(request)
if err != nil {
return tccommon.RetryError(err, redis.INTERNALERROR)
}
return nil
})
} else {
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
_, err := service.UpgradeInstance(ctx, d.Id(), memSize, shardNum, redisReplicaCount+len(adds), addNodes)
if err != nil {
return tccommon.RetryError(err, redis.FAILEDOPERATION_UNKNOWN)
}
return nil
})
}
if err != nil {
return err
}
Expand Down

0 comments on commit 4373fd7

Please sign in to comment.