diff --git a/.changelog/3390.txt b/.changelog/3390.txt new file mode 100644 index 0000000000..9b8af60ea6 --- /dev/null +++ b/.changelog/3390.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_as_start_instance_refresh: update retry code logic +``` \ No newline at end of file diff --git a/tencentcloud/services/as/resource_tc_as_start_instance_refresh.go b/tencentcloud/services/as/resource_tc_as_start_instance_refresh.go index b85c8306a9..158c6b9fc8 100644 --- a/tencentcloud/services/as/resource_tc_as_start_instance_refresh.go +++ b/tencentcloud/services/as/resource_tc_as_start_instance_refresh.go @@ -81,7 +81,7 @@ func ResourceTencentCloudAsStartInstanceRefresh() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - Description: "Refresh mode, currently, only rolling updates are supported, with the default value being ROLLING_UPDATE_RESET.", + Description: "Refresh mode. Value range: ROLLING_UPDATE_RESET: Reinstall the system for rolling update; ROLLING_UPDATE_REPLACE: Create a new instance for rolling update. This mode does not support the rollback interface yet.", }, }, } @@ -174,15 +174,20 @@ func resourceTencentCloudAsStartInstanceRefreshCreate(d *schema.ResourceData, me } if result == nil || result.Response == nil || len(result.Response.RefreshActivitySet) != 1 { - e = fmt.Errorf("create as start instance refresh failed.") - return resource.NonRetryableError(e) + return resource.NonRetryableError(fmt.Errorf("Create as start instance refresh failed.")) + } + + refreshStatus := result.Response.RefreshActivitySet[0].Status + refreshActivityId := result.Response.RefreshActivitySet[0].RefreshActivityId + if refreshStatus == nil || refreshActivityId == nil { + return resource.NonRetryableError(fmt.Errorf("Status or RefreshActivityId is nil.")) } - if *result.Response.RefreshActivitySet[0].Status == REFRESH_ACTIVITIES_SUCCESSFUL { + if *refreshStatus == REFRESH_ACTIVITIES_SUCCESSFUL { return nil } - return resource.RetryableError(fmt.Errorf("start instance refresh is still in running, state %s", *result.Response.RefreshActivitySet[0].Status)) + return resource.RetryableError(fmt.Errorf("Start instance refresh is still in running. Status: %s, RefreshActivityId: %s.", *refreshStatus, *refreshActivityId)) }) if err != nil { diff --git a/website/docs/r/as_start_instance_refresh.html.markdown b/website/docs/r/as_start_instance_refresh.html.markdown index 38697d2ff6..d367e1363d 100644 --- a/website/docs/r/as_start_instance_refresh.html.markdown +++ b/website/docs/r/as_start_instance_refresh.html.markdown @@ -39,7 +39,7 @@ The following arguments are supported: * `auto_scaling_group_id` - (Required, String, ForceNew) Scaling group ID. * `refresh_settings` - (Required, List, ForceNew) Refresh settings. -* `refresh_mode` - (Optional, String, ForceNew) Refresh mode, currently, only rolling updates are supported, with the default value being ROLLING_UPDATE_RESET. +* `refresh_mode` - (Optional, String, ForceNew) Refresh mode. Value range: ROLLING_UPDATE_RESET: Reinstall the system for rolling update; ROLLING_UPDATE_REPLACE: Create a new instance for rolling update. This mode does not support the rollback interface yet. The `refresh_settings` object supports the following: