Skip to content
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

import node-pool #2138

Merged
merged 1 commit into from
Sep 27, 2023
Merged

import node-pool #2138

merged 1 commit into from
Sep 27, 2023

Conversation

xiaokouliu
Copy link
Contributor

@xiaokouliu xiaokouliu commented Sep 20, 2023

  1. import node pool
  2. fix the bug of node pool created by custom image
  3. add deletion protection

// Optional: true,
// Description: "Indicates whether the node pool deletion protection is enabled.",
//},
"deletion_protection": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里调整了默认值吗?存量的会有change吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里新增deletion_protection字段,之前仅在code写了,但没有使用

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里本地要测试一下:老的provider升级到这个provider后,用户本地会不会有diff产生。

Type: schema.TypeString,
Optional: true,
Default: "GENERAL",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥要加这段逻辑呢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修复自定镜像时,不能指定node_os_type参数值的

)
if len(items) != 2 {
return fmt.Errorf("resource_tc_kubernetes_node_pool id is broken")
}
clusterId := items[0]
nodePoolId := items[1]

if _, ok := d.GetOkExists("cluster_id"); !ok {
fmt.Printf("xxxxxx")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个打印语句要去掉吧

@@ -1105,6 +1126,9 @@ func resourceKubernetesNodePoolRead(d *schema.ResourceData, meta interface{}) er
_ = d.Set("node_count", AutoscalingAddedTotal+ManuallyAddedTotal)
_ = d.Set("auto_scaling_group_id", nodePool.AutoscalingGroupId)
_ = d.Set("launch_config_id", nodePool.LaunchConfigurationId)
if _, ok := d.GetOkExists("unschedulable"); !ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是新加的字段吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unschedulable字段不是新增字段的,unschedulable字段设置默认值0,所以需要在纳管逻辑中添加该字段

@@ -1221,8 +1250,11 @@ func resourceKubernetesNodePoolRead(d *schema.ResourceData, meta interface{}) er
}

if launchCfg.SecurityGroupIds != nil {
launchConfig["security_group_ids"] = helper.StringsInterfaces(launchCfg.SecurityGroupIds)
launchConfig["orderly_security_group_ids"] = helper.StringsInterfaces(launchCfg.SecurityGroupIds)
if _, ok := d.GetOk("security_group_ids"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里加了if else 会有问题吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security_group_ids是Computed: true,把这个属性忽略了,恢复一下

nodeConfig["gpu_args"] = []map[string]interface{}{gpuArgs}
}
nodeConfigs = append(nodeConfigs, nodeConfig)
_ = d.Set("node_config", nodeConfigs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_config也是新增字段是吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_config不是新增字段,是新增的读取信息的逻辑,仅对纳管使用

@@ -0,0 +1,3 @@
```release-note:enhancement
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新加的功能是不是要补充下e2e测试

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试大佬测试过

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试大佬测试过

需要在 tencentcloud/resource_tc_kubernetes_node_pool_test.go 中补充e2e自动化测试覆盖

}

if importFlag {
if dMap, ok := helper.InterfacesHeadMap(d, "node_config"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段逻辑要去掉吧

// If not check, the diff between computed and default empty value leads to force replacement
if _, ok := d.GetOk("multi_zone_subnet_policy"); ok {
_ = d.Set("multi_zone_subnet_policy", asg.MultiZoneSubnetPolicy)
}
}
if v, ok := d.GetOkExists("delete_keep_instance"); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为啥需要加 if 判断呢

@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_kubernetes_node_pool: import node_pool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个changelog什么意思呢?重新写下吧

"deletion_protection": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你们接口不传DeletionProtection,本身默认就是false吧。
如果是,这里不要加Default和DiffSuppressFunc,现在加了无形增加代码复杂度。
DiffSuppressFunc本身就是用于正常方案失效时的“兜底”选择。

// Optional: true,
// Description: "Indicates whether the node pool deletion protection is enabled.",
//},
"deletion_protection": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里本地要测试一下:老的provider升级到这个provider后,用户本地会不会有diff产生。

)
if len(items) != 2 {
return fmt.Errorf("resource_tc_kubernetes_node_pool id is broken")
}
clusterId := items[0]
nodePoolId := items[1]

if _, ok := d.GetOkExists("cluster_id"); !ok {
importFlag = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.这是要干什么?
2.cluster_id本身是required

Copy link
Collaborator

@andrew-tx andrew-tx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

)
if len(items) != 2 {
return fmt.Errorf("resource_tc_kubernetes_node_pool id is broken")
}
clusterId := items[0]
nodePoolId := items[1]

if v, ok := d.GetOk("import_flag"); ok {
importFlag = v.(bool)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

设置为false操作要在这个if里操作。否则非import流程会多一个import_flag。
d.Set("import_flag", false)

@@ -617,9 +626,23 @@ func resourceTencentCloudKubernetesNodePool() *schema.Resource {
Computed: true,
Description: "The auto scaling group ID.",
},
"import_flag": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不要把import_flag暴露出来

@lyu571
Copy link
Collaborator

lyu571 commented Sep 27, 2023

LGTM

@lyu571 lyu571 merged commit 703420f into tencentcloudstack:master Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants