Skip to content

fix(tke): [119976364] tencentcloud_kubernetes_scale_worker add params create_result_output_file #2885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2885.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_kubernetes_scale_worker: add params `create_result_output_file`
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Provide a resource to increase instance to cluster

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

~> **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

Example Usage

```hcl
Expand Down Expand Up @@ -49,6 +51,8 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
user_data = "dGVzdA=="
password = "AABBccdd1122"
}

create_result_output_file = "my_output_file_path"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,13 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
waitRequest := tke.NewDescribeClusterInstancesRequest()
waitRequest.ClusterId = &clusterId
waitRequest.InstanceIds = helper.Strings(instanceIds)
tmpList := []*tke.Instance{}
err = resource.Retry(tccommon.ReadRetryTimeout*5, func() *resource.RetryError {
var (
offset int64 = 0
limit int64 = 100
tmpInstanceSet []*tke.Instance
offset int64 = 0
limit int64 = 100
tmpInstanceSet []*tke.Instance
createErrorList []*tke.Instance
)

// get all instances
Expand Down Expand Up @@ -512,14 +514,17 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
flag = true
} else if *instance.InstanceState == "failed" {
stop += 1
createErrorList = append(createErrorList, instance)
log.Printf("instance: %s status is failed.", v)
} else {
createErrorList = append(createErrorList, instance)
continue
}
}
}
}

tmpList = createErrorList
if stop == len(instanceIds) && flag {
return nil
} else if stop == len(instanceIds) && !flag {
Expand All @@ -530,6 +535,13 @@ func resourceTencentCloudKubernetesScaleWorkerCreateOnStart(ctx context.Context)
}
})

output, ok := d.GetOk("create_result_output_file")
if ok && output.(string) != "" {
if e := tccommon.WriteToFile(output.(string), tmpList); e != nil {
return e
}
}

if err != nil {
log.Printf("[CRITAL] kubernetes scale worker instances status error, reason:%+v", err)
return err
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/kubernetes_scale_worker.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Provide a resource to increase instance to cluster

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

~> **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

## Example Usage

```hcl
Expand Down Expand Up @@ -60,6 +62,8 @@ resource "tencentcloud_kubernetes_scale_worker" "example" {
user_data = "dGVzdA=="
password = "AABBccdd1122"
}

create_result_output_file = "my_output_file_path"
}
```

Expand Down Expand Up @@ -120,6 +124,7 @@ The following arguments are supported:

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