Skip to content

Commit d5122f8

Browse files
committed
fix: modify gateway
1 parent e87c804 commit d5122f8

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

tencentcloud/resource_tc_tse_cngw_gateway.go

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func resourceTencentCloudTseCngwGateway() *schema.Resource {
145145

146146
"feature_version": {
147147
Optional: true,
148+
Computed: true,
148149
Type: schema.TypeString,
149150
Description: "product version. Reference value: `TRIAL`, `STANDARD`(default value), `PROFESSIONAL`.",
150151
},
@@ -157,12 +158,14 @@ func resourceTencentCloudTseCngwGateway() *schema.Resource {
157158

158159
"engine_region": {
159160
Optional: true,
161+
Computed: true,
160162
Type: schema.TypeString,
161163
Description: "engine region of gateway.",
162164
},
163165

164166
"ingress_class_name": {
165167
Optional: true,
168+
Computed: true,
166169
Type: schema.TypeString,
167170
Description: "ingress class name.",
168171
},
@@ -486,7 +489,7 @@ func resourceTencentCloudTseCngwGatewayUpdate(d *schema.ResourceData, meta inter
486489

487490
request.GatewayId = &gatewayId
488491

489-
immutableArgs := []string{"type", "gateway_version", "node_config", "vpc_config", "feature_version", "internet_max_bandwidth_out", "engine_region", "ingress_class_name", "trade_type", "internet_config"}
492+
immutableArgs := []string{"type", "gateway_version", "vpc_config", "feature_version", "internet_max_bandwidth_out", "engine_region", "ingress_class_name", "trade_type", "internet_config"}
490493
for _, v := range immutableArgs {
491494
if d.HasChange(v) {
492495
return fmt.Errorf("argument `%s` cannot be changed", v)
@@ -536,6 +539,60 @@ func resourceTencentCloudTseCngwGatewayUpdate(d *schema.ResourceData, meta inter
536539
}
537540
}
538541

542+
if d.HasChange("node_config") {
543+
// Get the default group id
544+
paramMap := make(map[string]interface{})
545+
paramMap["GatewayId"] = &gatewayId
546+
service := TseService{client: meta.(*TencentCloudClient).apiV3Conn}
547+
cngwGroup, err := service.DescribeTseGroupsByFilter(ctx, paramMap)
548+
if err != nil {
549+
return err
550+
}
551+
if len(cngwGroup.GatewayGroupList) < 1 {
552+
return fmt.Errorf("[WARN]%s resource `TseCngwGroup` [%s] not found, please check if it has been deleted.\n", logId, gatewayId)
553+
}
554+
groupId := ""
555+
for _, v := range cngwGroup.GatewayGroupList {
556+
if *v.IsFirstGroup == 1 {
557+
groupId = *v.GroupId
558+
break
559+
}
560+
}
561+
562+
nodeConfigRequest := tse.NewUpdateCloudNativeAPIGatewaySpecRequest()
563+
nodeConfigRequest.GatewayId = &gatewayId
564+
nodeConfigRequest.GroupId = &groupId
565+
566+
if dMap, ok := helper.InterfacesHeadMap(d, "node_config"); ok {
567+
cloudNativeAPIGatewayNodeConfig := tse.CloudNativeAPIGatewayNodeConfig{}
568+
if v, ok := dMap["specification"]; ok {
569+
cloudNativeAPIGatewayNodeConfig.Specification = helper.String(v.(string))
570+
}
571+
if v, ok := dMap["number"]; ok {
572+
cloudNativeAPIGatewayNodeConfig.Number = helper.IntInt64(v.(int))
573+
}
574+
nodeConfigRequest.NodeConfig = &cloudNativeAPIGatewayNodeConfig
575+
}
576+
577+
err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
578+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseTseClient().UpdateCloudNativeAPIGatewaySpec(nodeConfigRequest)
579+
if e != nil {
580+
return retryError(e)
581+
} else {
582+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, nodeConfigRequest.GetAction(), nodeConfigRequest.ToJsonString(), result.ToJsonString())
583+
}
584+
return nil
585+
})
586+
if err != nil {
587+
log.Printf("[CRITAL]%s update tse cngwGateway failed, reason:%+v", logId, err)
588+
return err
589+
}
590+
591+
if err := service.CheckTseNativeAPIGatewayGroupStatusById(ctx, gatewayId, groupId, "update"); err != nil {
592+
return err
593+
}
594+
}
595+
539596
if d.HasChange("tags") {
540597
ctx := context.WithValue(context.TODO(), logIdKey, logId)
541598
tcClient := meta.(*TencentCloudClient).apiV3Conn

tencentcloud/resource_tc_tse_cngw_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func resourceTencentCloudTseCngwService() *schema.Resource {
245245
"algorithm": {
246246
Type: schema.TypeString,
247247
Optional: true,
248+
Computed: true,
248249
Description: "load balance algorithm,default: `round-robin`, `least-connections` and `consisten_hashing` also support.",
249250
},
250251
"auto_scaling_group_id": {

tencentcloud/service_tencentcloud_tse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ func (me *TseService) CheckTseNativeAPIGatewayGroupStatusById(ctx context.Contex
12171217
return resource.NonRetryableError(fmt.Errorf("group %s not exists", groupId))
12181218
}
12191219

1220-
if *gateway.Status == "Modifying" {
1220+
if *gateway.Status == "Modifying" || *gateway.Status == "UpdatingSpec" {
12211221
return resource.RetryableError(fmt.Errorf("update group status is %v,start retrying ...", *gateway.Status))
12221222
}
12231223
if *gateway.Status == "Running" {

0 commit comments

Comments
 (0)