Skip to content

Commit 39d22ec

Browse files
authored
fix: cvm chargetype update polling status (#915)
1 parent 58b5477 commit 39d22ec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tencentcloud/resource_tc_instance.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,11 +1023,17 @@ func resourceTencentCloudInstanceUpdate(d *schema.ResourceData, meta interface{}
10231023
if errRet != nil {
10241024
return retryError(errRet, InternalError)
10251025
}
1026-
if instance != nil && (*instance.InstanceState == CVM_STATUS_RUNNING ||
1027-
*instance.InstanceState == CVM_STATUS_LAUNCH_FAILED) {
1028-
return nil
1026+
if instance != nil && instance.LatestOperationState != nil {
1027+
if *instance.LatestOperationState == CVM_LATEST_OPERATION_STATE_OPERATING {
1028+
return resource.RetryableError(fmt.Errorf("cvm instance status is %s, retry...", *instance.LatestOperationState))
1029+
}
1030+
if *instance.LatestOperationState == CVM_LATEST_OPERATION_STATE_FAILED {
1031+
return resource.NonRetryableError(fmt.Errorf("failed operation when modify instance charge type"))
1032+
}
1033+
} else if instance != nil && *instance.InstanceChargeType == CVM_CHARGE_TYPE_POSTPAID {
1034+
return resource.RetryableError(fmt.Errorf("cvm charge type is still %s, retry", CVM_CHARGE_TYPE_POSTPAID))
10291035
}
1030-
return resource.RetryableError(fmt.Errorf("cvm instance status is %s, retry...", *instance.InstanceState))
1036+
return nil
10311037
})
10321038
if err != nil {
10331039
return err

0 commit comments

Comments
 (0)