Skip to content

Commit

Permalink
resource/alicloud_lindorm_instance: Added retry strategy for error co…
Browse files Browse the repository at this point in the history
…de OperationDenied.OrderProcessing, Instance.IsNotValid
  • Loading branch information
MrWolong committed Feb 27, 2024
1 parent 6256761 commit e4a2d71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 5 additions & 3 deletions alicloud/resource_alicloud_lindorm_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func resourceAliCloudLindormInstanceUpdate(d *schema.ResourceData, meta interfac
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-06-15"), StringPointer("AK"), nil, request, &runtime)
if err != nil {
if IsExpectedErrors(err, []string{"Instance.NotActive"}) || NeedRetry(err) {
if IsExpectedErrors(err, []string{"Instance.IsNotValid"}) || NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
Expand Down Expand Up @@ -674,7 +674,7 @@ func resourceAliCloudLindormInstanceUpdate(d *schema.ResourceData, meta interfac
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-06-15"), StringPointer("AK"), nil, updateLindormInstanceAttributeReq, &runtime)
if err != nil {
if IsExpectedErrors(err, []string{"Instance.NotActive"}) || NeedRetry(err) {
if IsExpectedErrors(err, []string{"Instance.IsNotValid"}) || NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
Expand Down Expand Up @@ -1143,7 +1143,7 @@ func UpgradeLindormInstance(d *schema.ResourceData, meta interface{}, request ma
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2020-06-15"), StringPointer("AK"), nil, request, &runtime)
if err != nil {
if IsExpectedErrors(err, []string{"Instance.NotActive"}) || NeedRetry(err) {
if IsExpectedErrors(err, []string{"Instance.NotActive", "OperationDenied.OrderProcessing"}) || NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
Expand All @@ -1152,6 +1152,7 @@ func UpgradeLindormInstance(d *schema.ResourceData, meta interface{}, request ma
return nil
})
addDebug(action, response, request)

if err != nil {
return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR)
}
Expand All @@ -1161,5 +1162,6 @@ func UpgradeLindormInstance(d *schema.ResourceData, meta interface{}, request ma
if _, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id())
}

return nil
}
11 changes: 5 additions & 6 deletions alicloud/resource_alicloud_lindorm_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,11 @@ func TestAccAliCloudLindormInstance_basic3(t *testing.T) {
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"disk_category": "local_ssd_pro",
"payment_type": "PayAsYouGo",
"instance_name": name,
"core_spec": "lindorm.i2.4xlarge",
"file_engine_specification": CHECKSET,
"instance_storage": CHECKSET,
"disk_category": "local_ssd_pro",
"payment_type": "PayAsYouGo",
"instance_name": name,
"core_spec": "lindorm.i2.4xlarge",
"instance_storage": CHECKSET,
}),
),
},
Expand Down

0 comments on commit e4a2d71

Please sign in to comment.