Skip to content

Commit

Permalink
resource/alicloud_nas_file_system: add retry code for update and dele…
Browse files Browse the repository at this point in the history
…te operation.
  • Loading branch information
ChenHanZhang committed Feb 8, 2024
1 parent 5d06c53 commit bb323ce
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 28 deletions.
12 changes: 6 additions & 6 deletions alicloud/resource_alicloud_nas_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func resourceAlicloudNasFileSystem() *schema.Resource {
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
Create: schema.DefaultTimeout(30 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
Schema: map[string]*schema.Schema{
"storage_type": {
Expand Down Expand Up @@ -194,7 +194,7 @@ func resourceAlicloudNasFileSystemUpdate(d *schema.ResourceData, meta interface{
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2017-06-26"), StringPointer("AK"), nil, request, &util.RuntimeOptions{})
if err != nil {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering}) {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering, "OperationDenied.InvalidState"}) {
wait()
return resource.RetryableError(err)
}
Expand All @@ -219,7 +219,7 @@ func resourceAlicloudNasFileSystemUpdate(d *schema.ResourceData, meta interface{
err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutUpdate)), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2017-06-26"), StringPointer("AK"), nil, request, &util.RuntimeOptions{})
if err != nil {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering}) {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering, "OperationDenied.InvalidState"}) {
wait()
return resource.RetryableError(err)
}
Expand Down Expand Up @@ -284,7 +284,7 @@ func resourceAlicloudNasFileSystemDelete(d *schema.ResourceData, meta interface{
err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2017-06-26"), StringPointer("AK"), nil, request, &util.RuntimeOptions{})
if err != nil {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering}) {
if NeedRetry(err) || IsExpectedErrors(err, []string{InvalidFileSystemStatus_Ordering, "OperationDenied.InvalidState"}) {
wait()
return resource.RetryableError(err)
}
Expand Down
25 changes: 11 additions & 14 deletions alicloud/resource_alicloud_nas_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,17 @@ func TestAccAlicloudNASFileSystemExtreme_basic(t *testing.T) {
Config: testAccConfig(map[string]interface{}{
"protocol_type": "NFS",
"zone_id": "${local.zone_id}",
"storage_type": "standard",
"storage_type": "advance",
"file_system_type": "extreme",
"capacity": "100",
"description": name,
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"protocol_type": CHECKSET,
"zone_id": CHECKSET,
"storage_type": "standard",
"storage_type": "advance",
"file_system_type": "extreme",
"capacity": "100",
"description": name,
}),
),
},
Expand Down Expand Up @@ -427,22 +425,20 @@ func TestAccAlicloudNASFileSystemExtremeEncrypt(t *testing.T) {
Config: testAccConfig(map[string]interface{}{
"protocol_type": "NFS",
"zone_id": "${local.zone_id}",
"storage_type": "standard",
"storage_type": "advance",
"file_system_type": "extreme",
"capacity": "100",
"encrypt_type": "2",
"kms_key_id": "${alicloud_kms_key.key.id}",
"description": name,
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"protocol_type": CHECKSET,
"zone_id": CHECKSET,
"storage_type": "standard",
"storage_type": "advance",
"file_system_type": "extreme",
"capacity": "100",
"encrypt_type": "2",
"description": name,
}),
),
},
Expand Down Expand Up @@ -539,18 +535,18 @@ func TestAccAlicloudNASFileSystemCpfs_basic(t *testing.T) {
"capacity": "3600",
"vpc_id": "${data.alicloud_vpcs.default.ids.0}",
"vswitch_id": "${data.alicloud_vswitches.default.ids.0}",
"description": name,
//"description": name,
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"protocol_type": CHECKSET,
"zone_id": CHECKSET,
"storage_type": "advance_200",
"file_system_type": "cpfs",
"capacity": "100",
"capacity": "3600",
"vpc_id": CHECKSET,
"vswitch_id": CHECKSET,
"description": name,
//"description": name,
}),
),
},
Expand Down Expand Up @@ -609,9 +605,10 @@ func TestAccAlicloudNASFileSystemCpfs_basic(t *testing.T) {
),
},
{
ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"vpc_id", "vswitch_id"},
},
},
})
Expand Down
1 change: 0 additions & 1 deletion alicloud/resource_alicloud_nas_fileset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ resource "alicloud_nas_file_system" "default" {
storage_type = "advance_200"
file_system_type = "cpfs"
capacity = 3600
description = "tf-testacc"
zone_id = local.zone_id
vpc_id = data.alicloud_vpcs.default.ids.0
vswitch_id = data.alicloud_vswitches.default.ids.0
Expand Down
10 changes: 5 additions & 5 deletions alicloud/resource_alicloud_nas_mount_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ resource "alicloud_vswitch" "main" {
}
resource "alicloud_nas_file_system" "example" {
protocol_type = "NFS"
storage_type = "advance"
capacity = "100"
zone_id = local.zone_id
file_system_type = "extreme"
file_system_type = "extreme"
protocol_type = "NFS"
zone_id = data.alicloud_nas_zones.default.zones[local.count_size - 1].zone_id
storage_type = "advance"
capacity = 100
}
resource "alicloud_nas_access_group" "example" {
Expand Down
3 changes: 1 addition & 2 deletions alicloud/resource_alicloud_nas_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ resource "alicloud_nas_file_system" "default" {
file_system_type = "extreme"
protocol_type = "NFS"
zone_id = data.alicloud_nas_zones.default.zones[local.count_size - 1].zone_id
storage_type = "standard"
description = var.name
storage_type = "advance"
capacity = 100
}
`, name)
Expand Down

0 comments on commit bb323ce

Please sign in to comment.