Skip to content

Commit bc4be5e

Browse files
tongyimingmikatong
and
mikatong
authored
fix(cfs): [137258363]retry the FailedOperation.PgroupIsUpdating error (#3134)
* retry the FailedOperation.PgroupIsUpdating error * add changelog --------- Co-authored-by: mikatong <[email protected]>
1 parent 4930720 commit bc4be5e

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.changelog/3134.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cfs_access_rule: retry the FailedOperation.PgroupIsUpdating error
3+
```

tencentcloud/services/cfs/extension_cfs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const (
2424
CFS_USER_PERMISSION_NO_ALL_SQUASH = "no_all_squash"
2525
CFS_USER_PERMISSION_ROOT_SQUASH = "root_squash"
2626
CFS_USER_PERMISSION_NO_ROOT_SQUASH = "no_root_squash"
27+
28+
FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR = "FailedOperation.PgroupIsUpdating"
2729
)
2830

2931
var CFS_STORAGETYPE = []string{

tencentcloud/services/cfs/resource_tc_cfs_access_rule.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1313
cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
1414

15+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
1516
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
1617
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
1718
)
@@ -76,6 +77,11 @@ func resourceTencentCloudCfsAccessRuleCreate(d *schema.ResourceData, meta interf
7677
if err != nil {
7778
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
7879
logId, request.GetAction(), request.ToJsonString(), err.Error())
80+
if e, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
81+
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
82+
return resource.RetryableError(err)
83+
}
84+
}
7985
return tccommon.RetryError(err)
8086
}
8187
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
@@ -162,6 +168,11 @@ func resourceTencentCloudCfsAccessRuleUpdate(d *schema.ResourceData, meta interf
162168
if err != nil {
163169
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
164170
logId, request.GetAction(), request.ToJsonString(), err.Error())
171+
if e, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
172+
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
173+
return resource.RetryableError(err)
174+
}
175+
}
165176
return tccommon.RetryError(err)
166177
}
167178
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
@@ -188,6 +199,11 @@ func resourceTencentCloudCfsAccessRuleDelete(d *schema.ResourceData, meta interf
188199
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
189200
errRet := cfsService.DeleteAccessRule(ctx, groupId, ruleId)
190201
if errRet != nil {
202+
if e, ok := errRet.(*sdkErrors.TencentCloudSDKError); ok {
203+
if e.GetCode() == FAILED_OPERATION_PGROUP_IS_UPDATING_ERROR {
204+
return resource.RetryableError(errRet)
205+
}
206+
}
191207
return tccommon.RetryError(errRet)
192208
}
193209
return nil

tencentcloud/services/cfs/resource_tc_cfs_access_rule_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1414
)
1515

16-
func TestAccTencentCloudCfsAccessRule(t *testing.T) {
16+
func TestAccTencentCloudCfsAccessRuleResource(t *testing.T) {
1717
t.Parallel()
1818
resource.Test(t, resource.TestCase{
1919
PreCheck: func() { tcacctest.AccPreCheck(t) },
@@ -97,10 +97,14 @@ func testAccCheckCfsAccessRuleExists(n string) resource.TestCheckFunc {
9797
}
9898
}
9999

100-
const testAccCfsAccessRule = DefaultCfsAccessGroup + `
100+
const testAccCfsAccessRule = `
101+
resource "tencentcloud_cfs_access_group" "foo" {
102+
name = "testAccessRuleGroup"
103+
description = "desc."
104+
}
101105
102106
resource "tencentcloud_cfs_access_rule" "foo" {
103-
access_group_id = local.cfs_access_group_id
107+
access_group_id = tencentcloud_cfs_access_group.foo.id
104108
auth_client_ip = "10.11.1.0/24"
105109
priority = 1
106110
}

0 commit comments

Comments
 (0)