Skip to content

Commit c6ec97b

Browse files
authored
fix(tke): [118694498] fix unschedulable cannot work. (#2764)
* fix(tke):[118694498]fix unschedulable cannot work. * add changelog and doc * adjust unschedulable * update e2e test case.
1 parent 01ff5e3 commit c6ec97b

6 files changed

+98
-16
lines changed

.changelog/2764.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_cluster_attachment: fix the issue that param `unschedulable` cannot work
3+
```

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
170170
Optional: true,
171171
ForceNew: true,
172172
Default: true,
173+
Deprecated: "This argument was deprecated, use `unschedulable` instead.",
173174
Description: "Indicate to schedule the adding node or not. Default is true.",
174175
},
175176
"desired_pod_num": {
@@ -234,13 +235,15 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
234235
Type: schema.TypeString,
235236
Optional: true,
236237
ForceNew: true,
238+
Deprecated: "This argument was no longer supported by TencentCloud TKE.",
237239
Description: "Mount target. Default is not mounting.",
238240
},
239241
"docker_graph_path": {
240242
Type: schema.TypeString,
241243
Optional: true,
242244
ForceNew: true,
243245
Default: "/var/lib/docker",
246+
Deprecated: "This argument was no longer supported by TencentCloud TKE.",
244247
Description: "Docker graph path. Default is `/var/lib/docker`.",
245248
},
246249
"data_disk": {
@@ -300,6 +303,7 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
300303
Type: schema.TypeList,
301304
Optional: true,
302305
ForceNew: true,
306+
Deprecated: "This argument was no longer supported by TencentCloud TKE.",
303307
Description: "Custom parameter information related to the node. This is a white-list parameter.",
304308
Elem: &schema.Schema{
305309
Type: schema.TypeString,
@@ -309,19 +313,22 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
309313
Type: schema.TypeString,
310314
Optional: true,
311315
ForceNew: true,
316+
Deprecated: "This argument was no longer supported by TencentCloud TKE.",
312317
Description: "Base64-encoded User Data text, the length limit is 16KB.",
313318
},
314319
"pre_start_user_script": {
315320
Type: schema.TypeString,
316321
Optional: true,
317322
ForceNew: true,
323+
Deprecated: "This argument was no longer supported by TencentCloud TKE.",
318324
Description: "Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.",
319325
},
320326
"is_schedule": {
321327
Type: schema.TypeBool,
322328
Optional: true,
323329
ForceNew: true,
324330
Default: true,
331+
Deprecated: "This argument was deprecated, use `unschedulable` instead.",
325332
Description: "Indicate to schedule the adding node or not. Default is true.",
326333
},
327334
"desired_pod_num": {
@@ -386,7 +393,7 @@ func ResourceTencentCloudKubernetesClusterAttachment() *schema.Resource {
386393
Optional: true,
387394
ForceNew: true,
388395
Default: 0,
389-
Description: "Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.",
396+
Description: "Sets whether the joining node participates in the schedule. Default is `0`, which means it participates in scheduling. Non-zero(eg: `1`) number means it does not participate in scheduling.",
390397
},
391398

392399
"security_groups": {
@@ -496,9 +503,6 @@ func resourceTencentCloudKubernetesClusterAttachmentCreate(d *schema.ResourceDat
496503
}
497504
instanceAdvancedSettings.GPUArgs = &gPUArgs
498505
}
499-
if v, ok := d.GetOkExists("unschedulable"); ok {
500-
instanceAdvancedSettings.Unschedulable = helper.IntInt64(v.(int))
501-
}
502506
request.InstanceAdvancedSettings = &instanceAdvancedSettings
503507
}
504508

@@ -557,9 +561,6 @@ func resourceTencentCloudKubernetesClusterAttachmentCreate(d *schema.ResourceDat
557561
}
558562
instanceAdvancedSettings.GPUArgs = &gPUArgs2
559563
}
560-
if v, ok := d.GetOkExists("unschedulable"); ok {
561-
instanceAdvancedSettings.Unschedulable = helper.IntInt64(v.(int))
562-
}
563564
request.InstanceAdvancedSettingsOverrides = append(request.InstanceAdvancedSettingsOverrides, &instanceAdvancedSettings)
564565
}
565566
}

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Provide a resource to attach an existing cvm to kubernetes cluster.
22

3+
~> **NOTE:** Use `unschedulable` to set whether the join node participates in the schedule. The `is_schedule` of 'worker_config' and 'worker_config_overrides' was deprecated.
4+
35
Example Usage
46

57
```hcl

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment_extension.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ func resourceTencentCloudKubernetesClusterAttachmentCreatePostFillRequest0(ctx c
4141
return fmt.Errorf("parameters `key_ids` and `password` must set and only set one")
4242
}
4343

44+
if req.InstanceAdvancedSettings == nil {
45+
req.InstanceAdvancedSettings = &tke.InstanceAdvancedSettings{}
46+
}
4447
// labels
4548
req.InstanceAdvancedSettings = &tke.InstanceAdvancedSettings{}
4649
req.InstanceAdvancedSettings.Labels = GetTkeLabels(d, "labels")
@@ -55,6 +58,11 @@ func resourceTencentCloudKubernetesClusterAttachmentCreatePostFillRequest0(ctx c
5558
}
5659
}
5760

61+
// only this unschedulable is valid, the is_schedule of worker_config and worker_config_overrides was deprecated.
62+
if v, ok := d.GetOkExists("unschedulable"); ok {
63+
req.InstanceAdvancedSettings.Unschedulable = helper.IntInt64(v.(int))
64+
}
65+
5866
// 检查是否已经绑定
5967
if hasAttached, err := nodeHasAttachedToCluster(ctx, instanceId, *req.ClusterId); err != nil {
6068
return err

tencentcloud/services/tke/resource_tc_kubernetes_cluster_attachment_test.go

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@ func TestAccTencentCloudKubernetesClusterAttachmentResource(t *testing.T) {
2727
testAccCheckTkeAttachExists("tencentcloud_kubernetes_cluster_attachment.test_attach"),
2828
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "cluster_id"),
2929
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "instance_id"),
30-
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "unschedulable"),
30+
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "unschedulable", "0"),
31+
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test1", "test1"),
32+
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test2", "test2"),
33+
),
34+
},
35+
{
36+
Config: testAccTkeAttachClusterUpdate(),
37+
Check: resource.ComposeTestCheckFunc(
38+
testAccCheckTkeAttachExists("tencentcloud_kubernetes_cluster_attachment.test_attach"),
39+
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "cluster_id"),
40+
resource.TestCheckResourceAttrSet("tencentcloud_kubernetes_cluster_attachment.test_attach", "instance_id"),
41+
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "unschedulable", "1"),
3142
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test1", "test1"),
3243
resource.TestCheckResourceAttr("tencentcloud_kubernetes_cluster_attachment.test_attach", "labels.test2", "test2"),
3344
),
@@ -206,3 +217,58 @@ resource "tencentcloud_kubernetes_cluster_attachment" "test_attach" {
206217
}
207218
`
208219
}
220+
221+
func testAccTkeAttachClusterUpdate() string {
222+
223+
return TkeNewDeps + `
224+
variable "cluster_cidr" {
225+
default = "10.31.0.0/16"
226+
}
227+
228+
variable "availability_zone" {
229+
default = "ap-guangzhou-3"
230+
}
231+
232+
data "tencentcloud_vpc_instances" "vpcs" {
233+
name = "keep_tke_exclusive_vpc"
234+
}
235+
236+
resource "tencentcloud_kubernetes_cluster" "example" {
237+
vpc_id = local.vpc_id
238+
cluster_cidr = var.cluster_cidr
239+
cluster_max_pod_num = 32
240+
cluster_name = "tf_example_cluster"
241+
cluster_desc = "example for tke cluster"
242+
cluster_max_service_num = 32
243+
cluster_internet = false # (can be ignored) open it after the nodes added
244+
cluster_version = "1.22.5"
245+
cluster_os = "tlinux2.2(tkernel3)x86_64"
246+
cluster_deploy_type = "MANAGED_CLUSTER"
247+
# without any worker config
248+
}
249+
250+
resource "tencentcloud_instance" "foo_attachment_new" {
251+
instance_name = "tf-auto-test-1-2"
252+
availability_zone = var.availability_zone
253+
image_id = var.default_img_id
254+
instance_type = local.final_type
255+
system_disk_type = "CLOUD_PREMIUM"
256+
system_disk_size = 50
257+
vpc_id = local.vpc_id
258+
subnet_id = local.subnet_id1
259+
}
260+
261+
resource "tencentcloud_kubernetes_cluster_attachment" "test_attach" {
262+
cluster_id = tencentcloud_kubernetes_cluster.example.id
263+
instance_id = tencentcloud_instance.foo_attachment_new.id
264+
password = "Lo4wbdit"
265+
unschedulable = 1
266+
267+
labels = {
268+
"test1" = "test1",
269+
"test2" = "test2",
270+
}
271+
272+
}
273+
`
274+
}

website/docs/r/kubernetes_cluster_attachment.html.markdown

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provide a resource to attach an existing cvm to kubernetes cluster.
1313

14+
~> **NOTE:** Use `unschedulable` to set whether the join node participates in the schedule. The `is_schedule` of 'worker_config' and 'worker_config_overrides' was deprecated.
15+
1416
## Example Usage
1517

1618
```hcl
@@ -115,7 +117,7 @@ The following arguments are supported:
115117
* `key_ids` - (Optional, List: [`String`], ForceNew) The key pair to use for the instance, it looks like skey-16jig7tx, it should be set if `password` not set.
116118
* `labels` - (Optional, Map, ForceNew) Labels of tke attachment exits CVM.
117119
* `password` - (Optional, String, ForceNew) Password to access, should be set if `key_ids` not set.
118-
* `unschedulable` - (Optional, Int, ForceNew) Sets whether the joining node participates in the schedule. Default is '0'. Participate in scheduling.
120+
* `unschedulable` - (Optional, Int, ForceNew) Sets whether the joining node participates in the schedule. Default is `0`, which means it participates in scheduling. Non-zero(eg: `1`) number means it does not participate in scheduling.
119121
* `worker_config_overrides` - (Optional, List, ForceNew) Override variable worker_config, commonly used to attach existing instances.
120122
* `worker_config` - (Optional, List, ForceNew) Deploy the machine configuration information of the 'WORKER', commonly used to attach existing instances.
121123

@@ -157,13 +159,13 @@ The `worker_config_overrides` object supports the following:
157159

158160
* `data_disk` - (Optional, List, ForceNew) Configurations of data disk.
159161
* `desired_pod_num` - (Optional, Int, ForceNew) Indicate to set desired pod number in node. valid when the cluster is podCIDR.
160-
* `docker_graph_path` - (Optional, String, ForceNew) Docker graph path. Default is `/var/lib/docker`.
161-
* `extra_args` - (Optional, List, ForceNew) Custom parameter information related to the node. This is a white-list parameter.
162+
* `docker_graph_path` - (Optional, String, ForceNew, **Deprecated**) This argument was no longer supported by TencentCloud TKE. Docker graph path. Default is `/var/lib/docker`.
163+
* `extra_args` - (Optional, List, ForceNew, **Deprecated**) This argument was no longer supported by TencentCloud TKE. Custom parameter information related to the node. This is a white-list parameter.
162164
* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters.
163-
* `is_schedule` - (Optional, Bool, ForceNew) Indicate to schedule the adding node or not. Default is true.
164-
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
165-
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
166-
* `user_data` - (Optional, String, ForceNew) Base64-encoded User Data text, the length limit is 16KB.
165+
* `is_schedule` - (Optional, Bool, ForceNew, **Deprecated**) This argument was deprecated, use `unschedulable` instead. Indicate to schedule the adding node or not. Default is true.
166+
* `mount_target` - (Optional, String, ForceNew, **Deprecated**) This argument was no longer supported by TencentCloud TKE. Mount target. Default is not mounting.
167+
* `pre_start_user_script` - (Optional, String, ForceNew, **Deprecated**) This argument was no longer supported by TencentCloud TKE. Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
168+
* `user_data` - (Optional, String, ForceNew, **Deprecated**) This argument was no longer supported by TencentCloud TKE. Base64-encoded User Data text, the length limit is 16KB.
167169

168170
The `worker_config` object supports the following:
169171

@@ -172,7 +174,7 @@ The `worker_config` object supports the following:
172174
* `docker_graph_path` - (Optional, String, ForceNew) Docker graph path. Default is `/var/lib/docker`.
173175
* `extra_args` - (Optional, List, ForceNew) Custom parameter information related to the node. This is a white-list parameter.
174176
* `gpu_args` - (Optional, List, ForceNew) GPU driver parameters.
175-
* `is_schedule` - (Optional, Bool, ForceNew) Indicate to schedule the adding node or not. Default is true.
177+
* `is_schedule` - (Optional, Bool, ForceNew, **Deprecated**) This argument was deprecated, use `unschedulable` instead. Indicate to schedule the adding node or not. Default is true.
176178
* `mount_target` - (Optional, String, ForceNew) Mount target. Default is not mounting.
177179
* `pre_start_user_script` - (Optional, String, ForceNew) Base64-encoded user script, executed before initializing the node, currently only effective for adding existing nodes.
178180
* `user_data` - (Optional, String, ForceNew) Base64-encoded User Data text, the length limit is 16KB.

0 commit comments

Comments
 (0)