Skip to content

Commit afae1bf

Browse files
tongyimingmikatong
andauthored
Fix/gaap tag retry (#1399)
* fix: gaap retry error * update gaap tag description * update all gaap proxy retry * add changelog Co-authored-by: mikatong <mikatong@tencent.com>
1 parent bde1ab9 commit afae1bf

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.changelog/1399.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/tencentcloud_gaap_proxy: fix gaap proxy retry error `DuplicatedRequest`
3+
```

tencentcloud/resource_tc_gaap_proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func resourceTencentCloudGaapProxy() *schema.Resource {
9696
"tags": {
9797
Type: schema.TypeMap,
9898
Optional: true,
99-
Description: "Tags of the GAAP proxy.",
99+
Description: "Tags of the GAAP proxy. Tags that do not exist are not created automatically.",
100100
},
101101

102102
// computed

tencentcloud/service_tencentcloud_gaap.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ func (me *GaapService) CreateProxy(
324324
createRequest.Concurrent = helper.IntUint64(concurrent)
325325
createRequest.AccessRegion = &accessRegion
326326
createRequest.RealServerRegion = &realserverRegion
327-
createRequest.ClientToken = helper.String(helper.BuildToken())
328327
for k, v := range tags {
329328
createRequest.TagSet = append(createRequest.TagSet, &gaap.TagPair{
330329
TagKey: helper.String(k),
@@ -334,6 +333,7 @@ func (me *GaapService) CreateProxy(
334333

335334
if err := resource.Retry(2*writeRetryTimeout, func() *resource.RetryError {
336335
ratelimit.Check(createRequest.GetAction())
336+
createRequest.ClientToken = helper.String(helper.BuildToken())
337337

338338
response, err := client.CreateProxy(createRequest)
339339
if err != nil {
@@ -412,10 +412,10 @@ func (me *GaapService) EnableProxy(ctx context.Context, id string) error {
412412

413413
enableRequest := gaap.NewOpenProxiesRequest()
414414
enableRequest.ProxyIds = []*string{&id}
415-
enableRequest.ClientToken = helper.String(helper.BuildToken())
416415

417416
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
418417
ratelimit.Check(enableRequest.GetAction())
418+
enableRequest.ClientToken = helper.String(helper.BuildToken())
419419

420420
response, err := client.OpenProxies(enableRequest)
421421
if err != nil {
@@ -491,10 +491,10 @@ func (me *GaapService) DisableProxy(ctx context.Context, id string) error {
491491

492492
disableRequest := gaap.NewCloseProxiesRequest()
493493
disableRequest.ProxyIds = []*string{&id}
494-
disableRequest.ClientToken = helper.String(helper.BuildToken())
495494

496495
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
497496
ratelimit.Check(disableRequest.GetAction())
497+
disableRequest.ClientToken = helper.String(helper.BuildToken())
498498

499499
response, err := client.CloseProxies(disableRequest)
500500
if err != nil {
@@ -649,10 +649,10 @@ func (me *GaapService) ModifyProxyName(ctx context.Context, id, name string) err
649649
request := gaap.NewModifyProxiesAttributeRequest()
650650
request.ProxyIds = []*string{&id}
651651
request.ProxyName = &name
652-
request.ClientToken = helper.String(helper.BuildToken())
653652

654653
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
655654
ratelimit.Check(request.GetAction())
655+
request.ClientToken = helper.String(helper.BuildToken())
656656

657657
if _, err := me.client.UseGaapClient().ModifyProxiesAttribute(request); err != nil {
658658
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]",
@@ -674,10 +674,10 @@ func (me *GaapService) ModifyProxyProjectId(ctx context.Context, id string, proj
674674
request := gaap.NewModifyProxiesProjectRequest()
675675
request.ProxyIds = []*string{&id}
676676
request.ProjectId = helper.IntInt64(projectId)
677-
request.ClientToken = helper.String(helper.BuildToken())
678677

679678
if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
680679
ratelimit.Check(request.GetAction())
680+
request.ClientToken = helper.String(helper.BuildToken())
681681

682682
if _, err := me.client.UseGaapClient().ModifyProxiesProject(request); err != nil {
683683
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]",
@@ -705,10 +705,10 @@ func (me *GaapService) ModifyProxyConfiguration(ctx context.Context, id string,
705705
if concurrent != nil {
706706
modifyRequest.Concurrent = helper.IntUint64(*concurrent)
707707
}
708-
modifyRequest.ClientToken = helper.String(helper.BuildToken())
709708

710709
if err := resource.Retry(2*writeRetryTimeout, func() *resource.RetryError {
711710
ratelimit.Check(modifyRequest.GetAction())
711+
modifyRequest.ClientToken = helper.String(helper.BuildToken())
712712

713713
if _, err := client.ModifyProxyConfiguration(modifyRequest); err != nil {
714714
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]",

website/docs/r/gaap_proxy.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The following arguments are supported:
3838
* `realserver_region` - (Required, String, ForceNew) Region of the GAAP realserver. Valid value: `NorthChina`, `EastChina`, `SouthChina`, `SouthwestChina`, `Hongkong`, `SL_TAIWAN`, `SoutheastAsia`, `Korea`, `SL_India`, `SL_Australia`, `Europe`, `SL_UK`, `SL_SouthAmerica`, `NorthAmerica`, `SL_MiddleUSA`, `Canada`, `SL_VIET`, `WestIndia`, `Thailand`, `Virginia`, `Russia`, `Japan` and `SL_Indonesia`.
3939
* `enable` - (Optional, Bool) Indicates whether GAAP proxy is enabled, default value is `true`.
4040
* `project_id` - (Optional, Int) ID of the project within the GAAP proxy, `0` means is default project.
41-
* `tags` - (Optional, Map) Tags of the GAAP proxy.
41+
* `tags` - (Optional, Map) Tags of the GAAP proxy. Tags that do not exist are not created automatically.
4242

4343
## Attributes Reference
4444

0 commit comments

Comments
 (0)