From 0f1ea98d2a87b95337b44c91beb5da6e5d205318 Mon Sep 17 00:00:00 2001 From: "maoshuai.17" Date: Tue, 5 Dec 2023 17:04:32 +0800 Subject: [PATCH 1/2] feat: support RetainResources in delete action --- volcengine/vke/addon/service_volcengine_vke_addon.go | 1 + volcengine/vke/cluster/service_volcengine_vke_cluster.go | 3 ++- .../service_volcengine_vke_default_node_pool.go | 5 +++-- volcengine/vke/node/service_volcengine_vke_node.go | 7 ++++--- .../vke/node_pool/resource_volcengine_vke_node_pool.go | 8 ++++---- .../vke/node_pool/service_volcengine_vke_node_pool.go | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/volcengine/vke/addon/service_volcengine_vke_addon.go b/volcengine/vke/addon/service_volcengine_vke_addon.go index edd8c944..e4b25c16 100644 --- a/volcengine/vke/addon/service_volcengine_vke_addon.go +++ b/volcengine/vke/addon/service_volcengine_vke_addon.go @@ -328,6 +328,7 @@ func (s *VolcengineVkeAddonService) RemoveResource(resourceData *schema.Resource } (*call.SdkParam)["ClusterId"] = ids[0] (*call.SdkParam)["Name"] = ids[1] + (*call.SdkParam)["RetainResources"] = []string{} (*call.SdkParam)["CascadingDeleteResources"] = []string{"Crd"} return true, nil }, diff --git a/volcengine/vke/cluster/service_volcengine_vke_cluster.go b/volcengine/vke/cluster/service_volcengine_vke_cluster.go index e2d1129d..7c3ae900 100644 --- a/volcengine/vke/cluster/service_volcengine_vke_cluster.go +++ b/volcengine/vke/cluster/service_volcengine_vke_cluster.go @@ -548,7 +548,8 @@ func (s *VolcengineVkeClusterService) RemoveResource(resourceData *schema.Resour ConvertMode: ve.RequestConvertIgnore, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { (*call.SdkParam)["Id"] = resourceData.Id() - (*call.SdkParam)["CascadingDeleteResources"] = []string{"NodePoolResource", "Clb", "Nat"} + (*call.SdkParam)["RetainResources"] = []string{} + (*call.SdkParam)["CascadingDeleteResources"] = []string{"All"} return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { diff --git a/volcengine/vke/default_node_pool/service_volcengine_vke_default_node_pool.go b/volcengine/vke/default_node_pool/service_volcengine_vke_default_node_pool.go index 53699ca6..8cf90a7f 100644 --- a/volcengine/vke/default_node_pool/service_volcengine_vke_default_node_pool.go +++ b/volcengine/vke/default_node_pool/service_volcengine_vke_default_node_pool.go @@ -418,8 +418,9 @@ func (s *VolcengineDefaultNodePoolService) RemoveResource(resourceData *schema.R ConvertMode: ve.RequestConvertIgnore, ContentType: ve.ContentTypeJson, SdkParam: &map[string]interface{}{ - "Id": resourceData.Id(), - "ClusterId": resourceData.Get("cluster_id"), + "Id": resourceData.Id(), + "ClusterId": resourceData.Get("cluster_id"), + "RetainResources": []string{"Ecs"}, }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) diff --git a/volcengine/vke/node/service_volcengine_vke_node.go b/volcengine/vke/node/service_volcengine_vke_node.go index c1688f6d..4fb5feec 100644 --- a/volcengine/vke/node/service_volcengine_vke_node.go +++ b/volcengine/vke/node/service_volcengine_vke_node.go @@ -242,9 +242,10 @@ func (s *VolcengineVkeNodeService) RemoveResource(resourceData *schema.ResourceD ConvertMode: ve.RequestConvertIgnore, ContentType: ve.ContentTypeJson, SdkParam: &map[string]interface{}{ - "ClusterId": resourceData.Get("cluster_id"), - "NodePoolId": resourceData.Get("node_pool_id"), - "Ids.1": resourceData.Id(), + "ClusterId": resourceData.Get("cluster_id"), + "NodePoolId": resourceData.Get("node_pool_id"), + "Ids.1": resourceData.Id(), + "RetainResources": []string{"Ecs"}, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { nodePool, err := s.nodePoolService.ReadResources(map[string]interface{}{ diff --git a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go index c314334f..d1acb776 100644 --- a/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/resource_volcengine_vke_node_pool.go @@ -62,20 +62,20 @@ func ResourceVolcengineNodePool() *schema.Resource { Type: schema.TypeBool, Optional: true, Computed: true, - Description: "Is Enabled of AutoScaling.", + Description: "Whether to enable the auto scaling function of the node pool. When a node needs to be manually added to the node pool, the value of this field must be `false`.", }, "max_replicas": { Type: schema.TypeInt, Optional: true, Default: 10, ValidateFunc: validation.IntBetween(1, 2000), - Description: "The MaxReplicas of AutoScaling, default 10, range in 1~2000.", + Description: "The MaxReplicas of AutoScaling, default 10, range in 1~2000. This field is valid when the value of `enabled` is `true`.", }, "min_replicas": { Type: schema.TypeInt, Optional: true, Computed: true, - Description: "The MinReplicas of AutoScaling, default 0.", + Description: "The MinReplicas of AutoScaling, default 0. This field is valid when the value of `enabled` is `true`.", }, "desired_replicas": { Type: schema.TypeInt, @@ -88,7 +88,7 @@ func ResourceVolcengineNodePool() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.IntBetween(0, 100), - Description: "The Priority of AutoScaling, default 10, rang in 0~100.", + Description: "The Priority of AutoScaling, default 10, rang in 0~100. This field is valid when the value of `enabled` is `true` and the value of `subnet_policy` is `Priority`.", }, "subnet_policy": { Type: schema.TypeString, diff --git a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go index 67e73a5a..ca110172 100644 --- a/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go +++ b/volcengine/vke/node_pool/service_volcengine_vke_node_pool.go @@ -756,7 +756,8 @@ func (s *VolcengineNodePoolService) RemoveResource(resourceData *schema.Resource SdkParam: &map[string]interface{}{ "Id": resourceData.Id(), "ClusterId": resourceData.Get("cluster_id"), - "CascadingDeleteResources": [1]string{"Ecs"}, + "RetainResources": []string{}, + "CascadingDeleteResources": []string{"Ecs"}, }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) From 8dee57cb26672bb9f2a17d9c8820e67ca61eb239 Mon Sep 17 00:00:00 2001 From: "maoshuai.17" Date: Mon, 18 Dec 2023 19:50:38 +0800 Subject: [PATCH 2/2] feat: update docs and version --- common/common_volcengine_version.go | 2 +- website/docs/r/vke_node_pool.html.markdown | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 2823c26f..a08c6dca 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.131" + TerraformProviderVersion = "0.0.132" ) diff --git a/website/docs/r/vke_node_pool.html.markdown b/website/docs/r/vke_node_pool.html.markdown index 35aa8fac..cc56af5a 100644 --- a/website/docs/r/vke_node_pool.html.markdown +++ b/website/docs/r/vke_node_pool.html.markdown @@ -140,10 +140,10 @@ The following arguments are supported: The `auto_scaling` object supports the following: * `desired_replicas` - (Optional) The DesiredReplicas of AutoScaling, default 0, range in min_replicas to max_replicas. -* `enabled` - (Optional) Is Enabled of AutoScaling. -* `max_replicas` - (Optional) The MaxReplicas of AutoScaling, default 10, range in 1~2000. -* `min_replicas` - (Optional) The MinReplicas of AutoScaling, default 0. -* `priority` - (Optional) The Priority of AutoScaling, default 10, rang in 0~100. +* `enabled` - (Optional) Whether to enable the auto scaling function of the node pool. When a node needs to be manually added to the node pool, the value of this field must be `false`. +* `max_replicas` - (Optional) The MaxReplicas of AutoScaling, default 10, range in 1~2000. This field is valid when the value of `enabled` is `true`. +* `min_replicas` - (Optional) The MinReplicas of AutoScaling, default 0. This field is valid when the value of `enabled` is `true`. +* `priority` - (Optional) The Priority of AutoScaling, default 10, rang in 0~100. This field is valid when the value of `enabled` is `true` and the value of `subnet_policy` is `Priority`. * `subnet_policy` - (Optional) Multi-subnet scheduling strategy for nodes. The value can be `ZoneBalance` or `Priority`. The `data_volumes` object supports the following: