Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3134.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_cfs_access_rule: retry the FailedOperation.PgroupIsUpdating error
```
2 changes: 2 additions & 0 deletions tencentcloud/services/cfs/extension_cfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const (
CFS_USER_PERMISSION_NO_ALL_SQUASH = "no_all_squash"
CFS_USER_PERMISSION_ROOT_SQUASH = "root_squash"
CFS_USER_PERMISSION_NO_ROOT_SQUASH = "no_root_squash"

FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR = "FailedOperation.PgroupIsUpdating"
)

var CFS_STORAGETYPE = []string{
Expand Down
16 changes: 16 additions & 0 deletions tencentcloud/services/cfs/resource_tc_cfs_access_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"

sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
)
Expand Down Expand Up @@ -76,6 +77,11 @@ func resourceTencentCloudCfsAccessRuleCreate(d *schema.ResourceData, meta interf
if err != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
logId, request.GetAction(), request.ToJsonString(), err.Error())
if e, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
return resource.RetryableError(err)
}
}
return tccommon.RetryError(err)
}
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
Expand Down Expand Up @@ -162,6 +168,11 @@ func resourceTencentCloudCfsAccessRuleUpdate(d *schema.ResourceData, meta interf
if err != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
logId, request.GetAction(), request.ToJsonString(), err.Error())
if e, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
return resource.RetryableError(err)
}
}
return tccommon.RetryError(err)
}
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
Expand All @@ -188,6 +199,11 @@ func resourceTencentCloudCfsAccessRuleDelete(d *schema.ResourceData, meta interf
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
errRet := cfsService.DeleteAccessRule(ctx, groupId, ruleId)
if errRet != nil {
if e, ok := errRet.(*sdkErrors.TencentCloudSDKError); ok {
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
return resource.RetryableError(errRet)
}
}
return tccommon.RetryError(errRet)
}
return nil
Expand Down
10 changes: 7 additions & 3 deletions tencentcloud/services/cfs/resource_tc_cfs_access_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccTencentCloudCfsAccessRule(t *testing.T) {
func TestAccTencentCloudCfsAccessRuleResource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Expand Down Expand Up @@ -97,10 +97,14 @@ func testAccCheckCfsAccessRuleExists(n string) resource.TestCheckFunc {
}
}

const testAccCfsAccessRule = DefaultCfsAccessGroup + `
const testAccCfsAccessRule = `
resource "tencentcloud_cfs_access_group" "foo" {
name = "testAccessRuleGroup"
description = "desc."
}

resource "tencentcloud_cfs_access_rule" "foo" {
access_group_id = local.cfs_access_group_id
access_group_id = tencentcloud_cfs_access_group.foo.id
auth_client_ip = "10.11.1.0/24"
priority = 1
}
Expand Down
Loading