Skip to content

Commit 23d7fa7

Browse files
tongyimingmikatong
andauthored
fix node_count (#1117)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent d2811ab commit 23d7fa7

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

tencentcloud/resource_tc_kubernetes_node_pool.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,16 @@ func ResourceTencentCloudKubernetesNodePool() *schema.Resource {
544544
Computed: true,
545545
Description: "The total node count.",
546546
},
547+
"autoscaling_added_total": {
548+
Type: schema.TypeInt,
549+
Computed: true,
550+
Description: "The total of autoscaling added node.",
551+
},
552+
"manually_added_total": {
553+
Type: schema.TypeInt,
554+
Computed: true,
555+
Description: "The total of manually added node.",
556+
},
547557
"launch_config_id": {
548558
Type: schema.TypeString,
549559
Computed: true,
@@ -927,7 +937,11 @@ func resourceKubernetesNodePoolRead(d *schema.ResourceData, meta interface{}) er
927937

928938
_ = d.Set("name", nodePool.Name)
929939
_ = d.Set("status", nodePool.LifeState)
930-
_ = d.Set("node_count", nodePool.NodeCountSummary)
940+
AutoscalingAddedTotal := *nodePool.NodeCountSummary.AutoscalingAdded.Total
941+
ManuallyAddedTotal := *nodePool.NodeCountSummary.ManuallyAdded.Total
942+
_ = d.Set("autoscaling_added_total", AutoscalingAddedTotal)
943+
_ = d.Set("manually_added_total", ManuallyAddedTotal)
944+
_ = d.Set("node_count", AutoscalingAddedTotal+ManuallyAddedTotal)
931945
_ = d.Set("auto_scaling_group_id", nodePool.AutoscalingGroupId)
932946
_ = d.Set("launch_config_id", nodePool.LaunchConfigurationId)
933947
//set not force new parameters

tencentcloud/resource_tc_kubernetes_node_pool_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func TestAccTencentCloudTkeNodePoolResource(t *testing.T) {
9494
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "default_cooldown", "400"),
9595
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "termination_policies.#", "1"),
9696
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "termination_policies.0", "OLDEST_INSTANCE"),
97+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "node_count", "1"),
98+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "autoscaling_added_total", "1"),
99+
resource.TestCheckResourceAttr(testTkeClusterNodePoolResourceKey, "manually_added_total", "0"),
97100
),
98101
},
99102
{
@@ -270,6 +273,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" {
270273
"root-dir=/var/lib/kubelet"
271274
]
272275
}
276+
node_os="Tencent tlinux release 2.2 (Final)"
273277
}
274278
`
275279

website/docs/r/kubernetes_node_pool.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ In addition to all arguments above, the following attributes are exported:
238238

239239
* `id` - ID of the resource.
240240
* `auto_scaling_group_id` - The auto scaling group ID.
241+
* `autoscaling_added_total` - The total of autoscaling added node.
241242
* `launch_config_id` - The launch config ID.
243+
* `manually_added_total` - The total of manually added node.
242244
* `node_count` - The total node count.
243245
* `status` - Status of the node pool.
244246

0 commit comments

Comments
 (0)