Skip to content

Commit 9488e5e

Browse files
authored
fix(tke): [118647966] fix worker_config.data_disk cannot work (#2769)
* fix(tke): [118647966] fix worker_config.data_disk cannot work * add changelog and doc * add e2e test
1 parent c6ec97b commit 9488e5e

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

.changelog/2769.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_kubernetes_scale_worker: fix param `data_disk` of worker_config cannot work
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.go

Lines changed: 13 additions & 2 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_extension.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func resourceTencentCloudKubernetesScaleWorkerReadPostRequest1(ctx context.Conte
136136
dataDisks = append(dataDisks, disk)
137137
}
138138
if importFlag1 {
139-
_ = d.Set("data_disk", dataDisks)
139+
_ = d.Set("data_disk", dataDisks) // out layer data_disk
140140
}
141141
}
142142

@@ -260,7 +260,7 @@ func resourceTencentCloudKubernetesScaleWorkerReadPostRequest2(ctx context.Conte
260260
dataDisks = append(dataDisks, dataDisk)
261261
}
262262

263-
mapping["data_disk"] = dataDisks
263+
mapping["data_disk"] = dataDisks // worker_config.data_disk
264264
instanceList = append(instanceList, mapping)
265265
}
266266
if importFlag1 {

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func TestAccTencentCloudKubernetesScaleWorkerResource(t *testing.T) {
114114
Check: resource.ComposeTestCheckFunc(
115115
testAccCheckTkeScaleWorkerExists(testTkeScaleWorkerResourceKey),
116116
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "cluster_id"),
117+
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "data_disk.0.file_system", "xfs"),
118+
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "data_disk.0.mount_target", "/data1"),
119+
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "data_disk.0.auto_format_and_mount", "true"),
117120
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_config.#"),
121+
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "worker_config.0.data_disk.0.encrypt", "true"),
118122
resource.TestCheckResourceAttr(testTkeScaleWorkerResourceKey, "worker_instances_list.#", "1"),
119123
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_instances_list.0.instance_id"),
120124
resource.TestCheckResourceAttrSet(testTkeScaleWorkerResourceKey, "worker_instances_list.0.instance_role"),
@@ -248,6 +252,14 @@ resource "tencentcloud_kubernetes_scale_worker" "test_scale" {
248252
pre_start_user_script = "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="
249253
user_script = "IyEvYmluL3NoIGVjaG8gImhlbGxvIHdvcmxkIg=="
250254
255+
data_disk {
256+
disk_type = "CLOUD_PREMIUM"
257+
disk_size = 50
258+
file_system = "xfs"
259+
mount_target = "/data1"
260+
auto_format_and_mount = true
261+
}
262+
251263
worker_config {
252264
count = 1
253265
availability_zone = "ap-guangzhou-3"
@@ -261,6 +273,7 @@ resource "tencentcloud_kubernetes_scale_worker" "test_scale" {
261273
data_disk {
262274
disk_type = "CLOUD_PREMIUM"
263275
disk_size = 50
276+
encrypt = true
264277
}
265278
266279
enhanced_security_service = false

website/docs/r/kubernetes_scale_worker.html.markdown

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The following arguments are supported:
118118

119119
* `cluster_id` - (Required, String, ForceNew) ID of the cluster.
120120
* `worker_config` - (Required, List, ForceNew) Deploy the machine configuration information of the 'WORK' service, and create <=20 units for common users.
121-
* `data_disk` - (Optional, List, ForceNew) Configurations of data disk.
121+
* `data_disk` - (Optional, List, ForceNew) Configurations of tke data disk.
122122
* `desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in current node. Valid when the cluster enable customized pod cidr.
123123
* `docker_graph_path` - (Optional, String, ForceNew) Docker graph path. Default is `/var/lib/docker`.
124124
* `extra_args` - (Optional, List: [`String`], ForceNew) Custom parameter information related to the node.
@@ -131,19 +131,20 @@ The following arguments are supported:
131131

132132
The `data_disk` object of `worker_config` supports the following:
133133

134-
* `auto_format_and_mount` - (Optional, Bool, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
135-
* `disk_partition` - (Optional, String, ForceNew) The name of the device or partition to mount.
134+
* `auto_format_and_mount` - (Optional, Bool, ForceNew, **Deprecated**) This argument was deprecated, use `data_disk` instead. Indicate whether to auto format and mount or not. Default is `false`.
135+
* `disk_partition` - (Optional, String, ForceNew, **Deprecated**) This argument was deprecated, use `data_disk` instead. The name of the device or partition to mount.
136136
* `disk_size` - (Optional, Int, ForceNew) Volume of disk in GB. Default is `0`.
137137
* `disk_type` - (Optional, String, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD` and `CLOUD_HSSD` and `CLOUD_TSSD`.
138138
* `encrypt` - (Optional, Bool) Indicates whether to encrypt data disk, default `false`.
139-
* `file_system` - (Optional, String, ForceNew) File system, e.g. `ext3/ext4/xfs`.
139+
* `file_system` - (Optional, String, ForceNew, **Deprecated**) This argument was deprecated, use `data_disk` instead. File system, e.g. `ext3/ext4/xfs`.
140140
* `kms_key_id` - (Optional, String) ID of the custom CMK in the format of UUID or `kms-abcd1234`. This parameter is used to encrypt cloud disks.
141-
* `mount_target` - (Optional, String, ForceNew) Mount target.
141+
* `mount_target` - (Optional, String, ForceNew, **Deprecated**) This argument was deprecated, use `data_disk` instead. Mount target.
142142
* `snapshot_id` - (Optional, String, ForceNew) Data disk snapshot ID.
143143

144144
The `data_disk` object supports the following:
145145

146146
* `auto_format_and_mount` - (Optional, Bool, ForceNew) Indicate whether to auto format and mount or not. Default is `false`.
147+
* `disk_partition` - (Optional, String, ForceNew) The name of the device or partition to mount.
147148
* `disk_size` - (Optional, Int, ForceNew) Volume of disk in GB. Default is `0`.
148149
* `disk_type` - (Optional, String, ForceNew) Types of disk, available values: `CLOUD_PREMIUM` and `CLOUD_SSD` and `CLOUD_HSSD` and `CLOUD_TSSD`.
149150
* `file_system` - (Optional, String, ForceNew) File system, e.g. `ext3/ext4/xfs`.
@@ -165,7 +166,7 @@ The `worker_config` object supports the following:
165166
* `bandwidth_package_id` - (Optional, String) bandwidth package id. if user is standard user, then the bandwidth_package_id is needed, or default has bandwidth_package_id.
166167
* `cam_role_name` - (Optional, String, ForceNew) CAM role name authorized to access.
167168
* `count` - (Optional, Int, ForceNew) Number of cvm.
168-
* `data_disk` - (Optional, List, ForceNew) Configurations of data disk.
169+
* `data_disk` - (Optional, List, ForceNew) Configurations of cvm data disk.
169170
* `desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it override `[globe_]desired_pod_num` for current node. Either all the fields `desired_pod_num` or none.
170171
* `disaster_recover_group_ids` - (Optional, List, ForceNew) Disaster recover groups to which a CVM instance belongs. Only support maximum 1.
171172
* `enhanced_monitor_service` - (Optional, Bool, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE.

0 commit comments

Comments
 (0)