Skip to content

Commit df1dcc5

Browse files
authored
add (#4158)
1 parent 61c9c12 commit df1dcc5

5 files changed

Lines changed: 46 additions & 13 deletions

File tree

.changelog/4158.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_kubernetes_encryption_protection: support custom timeouts
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_encryption_protection.go

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_encryption_protection_extension.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
89
tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"
910

1011
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
@@ -30,7 +31,7 @@ func resourceTencentCloudKubernetesEncryptionProtectionCreatePostHandleResponse0
3031
conf := tccommon.BuildStateChangeConf(
3132
[]string{},
3233
[]string{"Opened"},
33-
5*tccommon.ReadRetryTimeout,
34+
d.Timeout(schema.TimeoutCreate),
3435
time.Second,
3536
service.TkeEncryptionProtectionStateRefreshFunc(clusterId, []string{}),
3637
)
@@ -55,7 +56,7 @@ func resourceTencentCloudKubernetesEncryptionProtectionDeletePostHandleResponse0
5556
conf := tccommon.BuildStateChangeConf(
5657
[]string{},
5758
[]string{"Closed"},
58-
5*tccommon.ReadRetryTimeout,
59+
d.Timeout(schema.TimeoutDelete),
5960
time.Second,
6061
service.TkeEncryptionProtectionStateRefreshFunc(d.Id(), []string{}),
6162
)

tencentcloud/services/tke/service_tencentcloud_tke.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,15 +2849,24 @@ func (me *TkeService) TkeEncryptionProtectionStateRefreshFunc(clusterId string,
28492849
}
28502850
}()
28512851

2852-
object, err := me.client.UseTkeClient().DescribeEncryptionStatus(request)
2852+
var object *tke.DescribeEncryptionStatusResponse
2853+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
2854+
ratelimit.Check(request.GetAction())
2855+
result, e := me.client.UseTkeClient().DescribeEncryptionStatus(request)
2856+
if e != nil {
2857+
return tccommon.RetryError(e)
2858+
}
28532859

2854-
if err != nil {
2855-
return nil, "", err
2856-
}
2860+
if result == nil || result.Response == nil {
2861+
return resource.NonRetryableError(fmt.Errorf("Describe kubernetes encryption status failed, Response is nil."))
2862+
}
28572863

2864+
object = result
2865+
return nil
2866+
})
28582867
if err != nil {
28592868
errRet = err
2860-
return object, "", err
2869+
return nil, "", err
28612870
}
28622871

28632872
return object, helper.PString(object.Response.Status), nil
@@ -3204,9 +3213,21 @@ func (me *TkeService) DescribeKubernetesEncryptionProtectionById(ctx context.Con
32043213
}
32053214
}()
32063215

3207-
ratelimit.Check(request.GetAction())
3216+
var response *tke.DescribeEncryptionStatusResponse
3217+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
3218+
ratelimit.Check(request.GetAction())
3219+
result, e := me.client.UseTkeV20180525Client().DescribeEncryptionStatus(request)
3220+
if e != nil {
3221+
return tccommon.RetryError(e)
3222+
}
32083223

3209-
response, err := me.client.UseTkeV20180525Client().DescribeEncryptionStatus(request)
3224+
if result == nil || result.Response == nil {
3225+
return resource.NonRetryableError(fmt.Errorf("Describe kubernetes encryption status failed, Response is nil."))
3226+
}
3227+
3228+
response = result
3229+
return nil
3230+
})
32103231
if err != nil {
32113232
errRet = err
32123233
return

website/docs/r/kubernetes_encryption_protection.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,10 @@ In addition to all arguments above, the following attributes are exported:
7878
* `id` - ID of the resource.
7979
* `status` - kms encryption status.
8080

81+
## Timeouts
82+
83+
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions:
84+
85+
* `create` - (Defaults to `30m`) Used when creating the resource.
86+
* `delete` - (Defaults to `30m`) Used when deleting the resource.
8187

0 commit comments

Comments
 (0)