Skip to content

Commit dfcb35f

Browse files
authored
fix(tke): [119976364] tencentcloud_kubernetes_scale_worker add params create_result_output_file (#2885)
* add * add
1 parent d0416c2 commit dfcb35f

5 files changed

+34
-3
lines changed

.changelog/2885.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_scale_worker: add params `create_result_output_file`
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.go

Lines changed: 7 additions & 0 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_scale_worker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Provide a resource to increase instance to cluster
44

55
~> **NOTE:** Import Node: Currently, only one node can be imported at a time.
66

7+
~> **NOTE:** If you need to view error messages during instance creation, you can use parameter `create_result_output_file` to set the file save path
8+
79
Example Usage
810

911
```hcl
@@ -49,6 +51,8 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
4951
user_data = "dGVzdA=="
5052
password = "AABBccdd1122"
5153
}
54+
55+
create_result_output_file = "my_output_file_path"
5256
}
5357
```
5458

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_extension.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,13 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
463463
waitRequest := tke.NewDescribeClusterInstancesRequest()
464464
waitRequest.ClusterId = &clusterId
465465
waitRequest.InstanceIds = helper.Strings(instanceIds)
466+
tmpList := []*tke.Instance{}
466467
err = resource.Retry(tccommon.ReadRetryTimeout*5, func() *resource.RetryError {
467468
var (
468-
offset int64 = 0
469-
limit int64 = 100
470-
tmpInstanceSet []*tke.Instance
469+
offset int64 = 0
470+
limit int64 = 100
471+
tmpInstanceSet []*tke.Instance
472+
createErrorList []*tke.Instance
471473
)
472474

473475
// get all instances
@@ -512,14 +514,17 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
512514
flag = true
513515
} else if *instance.InstanceState == "failed" {
514516
stop += 1
517+
createErrorList = append(createErrorList, instance)
515518
log.Printf("instance: %s status is failed.", v)
516519
} else {
520+
createErrorList = append(createErrorList, instance)
517521
continue
518522
}
519523
}
520524
}
521525
}
522526

527+
tmpList = createErrorList
523528
if stop == len(instanceIds) && flag {
524529
return nil
525530
} else if stop == len(instanceIds) && !flag {
@@ -530,6 +535,13 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
530535
}
531536
})
532537

538+
output, ok := d.GetOk("create_result_output_file")
539+
if ok && output.(string) != "" {
540+
if e := tccommon.WriteToFile(output.(string), tmpList); e != nil {
541+
return e
542+
}
543+
}
544+
533545
if err != nil {
534546
log.Printf("[CRITAL] kubernetes scale worker instances status error, reason:%+v", err)
535547
return err

website/docs/r/kubernetes_scale_worker.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Provide a resource to increase instance to cluster
1515

1616
~> **NOTE:** Import Node: Currently, only one node can be imported at a time.
1717

18+
~> **NOTE:** If you need to view error messages during instance creation, you can use parameter `create_result_output_file` to set the file save path
19+
1820
## Example Usage
1921

2022
```hcl
@@ -60,6 +62,8 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
6062
user_data = "dGVzdA=="
6163
password = "AABBccdd1122"
6264
}
65+
66+
create_result_output_file = "my_output_file_path"
6367
}
6468
```
6569

@@ -120,6 +124,7 @@ The following arguments are supported:
120124

121125
* `cluster_id` - (Required, String, ForceNew) ID of the cluster.
122126
* `worker_config` - (Required, List, ForceNew) Deploy the machine configuration information of the 'WORK' service, and create <=20 units for common users.
127+
* `create_result_output_file` - (Optional, String, ForceNew) Used to save results of CVMs creation error messages.
123128
* `data_disk` - (Optional, List, ForceNew) Configurations of tke data disk.
124129
* `desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in current node. Valid when the cluster enable customized pod cidr.
125130
* `docker_graph_path` - (Optional, String, ForceNew) Docker graph path. Default is `/var/lib/docker`.

0 commit comments

Comments
 (0)