From f2a963d860045f8b823073baa93942a4a02c294e Mon Sep 17 00:00:00 2001 From: nikolay-spectro Date: Fri, 22 Sep 2023 16:04:58 -0700 Subject: [PATCH] PLT-695: Added additional meta attribute support for libvirt, edge-native, edge-vsphere. --- spectrocloud/resource_cluster_edge_native.go | 20 ++++++++++++++++++ spectrocloud/resource_cluster_edge_vsphere.go | 21 +++++++++++++++++++ spectrocloud/resource_cluster_libvirt.go | 21 +++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/spectrocloud/resource_cluster_edge_native.go b/spectrocloud/resource_cluster_edge_native.go index 2165e804..43b580fa 100644 --- a/spectrocloud/resource_cluster_edge_native.go +++ b/spectrocloud/resource_cluster_edge_native.go @@ -170,6 +170,12 @@ func resourceClusterEdgeNative() *schema.Resource { //ForceNew: true, Description: "Whether this machine pool is a control plane and a worker. Defaults to `false`.", }, + "node_repave_interval": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "Minimum number of seconds node should be Ready, before the next node is selected for repave. Default value is `0`, Applicable only for worker pools.", + }, "update_strategy": { Type: schema.TypeString, Optional: true, @@ -320,6 +326,7 @@ func flattenMachinePoolConfigsEdgeNative(machinePools []*models.V1EdgeNativeMach oi := make(map[string]interface{}) FlattenAdditionalLabelsAndTaints(machinePool.AdditionalLabels, machinePool.Taints, oi) + FlattenControlPlaneAndRepaveInterval(&machinePool.IsControlPlane, oi, machinePool.NodeRepaveInterval) oi["control_plane_as_worker"] = machinePool.UseControlPlaneAsWorker oi["name"] = machinePool.Name @@ -499,6 +506,19 @@ func toMachinePoolEdgeNative(machinePool interface{}) (*models.V1EdgeNativeMachi }, } + if !controlPlane { + nodeRepaveInterval := 0 + if m["node_repave_interval"] != nil { + nodeRepaveInterval = m["node_repave_interval"].(int) + } + mp.PoolConfig.NodeRepaveInterval = int32(nodeRepaveInterval) + } else { + err := ValidationNodeRepaveIntervalForControlPlane(m["node_repave_interval"].(int)) + if err != nil { + return mp, err + } + } + return mp, nil } diff --git a/spectrocloud/resource_cluster_edge_vsphere.go b/spectrocloud/resource_cluster_edge_vsphere.go index 77b640de..ce6690c4 100644 --- a/spectrocloud/resource_cluster_edge_vsphere.go +++ b/spectrocloud/resource_cluster_edge_vsphere.go @@ -182,6 +182,12 @@ func resourceClusterEdgeVsphere() *schema.Resource { Required: true, Description: "Number of nodes in the machine pool.", }, + "node_repave_interval": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "Minimum number of seconds node should be Ready, before the next node is selected for repave. Default value is `0`, Applicable only for worker pools.", + }, "update_strategy": { Type: schema.TypeString, Optional: true, @@ -355,6 +361,7 @@ func flattenMachinePoolConfigsEdgeVsphere(machinePools []*models.V1VsphereMachin oi := make(map[string]interface{}) FlattenAdditionalLabelsAndTaints(machinePool.AdditionalLabels, machinePool.Taints, oi) + FlattenControlPlaneAndRepaveInterval(machinePool.IsControlPlane, oi, machinePool.NodeRepaveInterval) oi["control_plane_as_worker"] = machinePool.UseControlPlaneAsWorker oi["name"] = machinePool.Name @@ -631,5 +638,19 @@ func toMachinePoolEdgeVsphere(machinePool interface{}) (*models.V1VsphereMachine }, } + if !controlPlane { + nodeRepaveInterval := 0 + if m["node_repave_interval"] != nil { + nodeRepaveInterval = m["node_repave_interval"].(int) + } + mp.PoolConfig.NodeRepaveInterval = int32(nodeRepaveInterval) + } else { + err := ValidationNodeRepaveIntervalForControlPlane(m["node_repave_interval"].(int)) + if err != nil { + return mp, err + } + + } + return mp, nil } diff --git a/spectrocloud/resource_cluster_libvirt.go b/spectrocloud/resource_cluster_libvirt.go index 4eb71496..0b18f307 100644 --- a/spectrocloud/resource_cluster_libvirt.go +++ b/spectrocloud/resource_cluster_libvirt.go @@ -191,6 +191,12 @@ func resourceClusterLibvirt() *schema.Resource { Required: true, Description: "Number of nodes in the machine pool.", }, + "node_repave_interval": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + Description: "Minimum number of seconds node should be Ready, before the next node is selected for repave. Default value is `0`, Applicable only for worker pools.", + }, "update_strategy": { Type: schema.TypeString, Optional: true, @@ -430,6 +436,7 @@ func flattenMachinePoolConfigsLibvirt(machinePools []*models.V1LibvirtMachinePoo oi := make(map[string]interface{}) FlattenAdditionalLabelsAndTaints(machinePool.AdditionalLabels, machinePool.Taints, oi) + FlattenControlPlaneAndRepaveInterval(&machinePool.IsControlPlane, oi, machinePool.NodeRepaveInterval) oi["control_plane_as_worker"] = machinePool.UseControlPlaneAsWorker oi["name"] = machinePool.Name @@ -737,6 +744,20 @@ func toMachinePoolLibvirt(machinePool interface{}) (*models.V1LibvirtMachinePool }, } + if !controlPlane { + nodeRepaveInterval := 0 + if m["node_repave_interval"] != nil { + nodeRepaveInterval = m["node_repave_interval"].(int) + } + mp.PoolConfig.NodeRepaveInterval = int32(nodeRepaveInterval) + } else { + err := ValidationNodeRepaveIntervalForControlPlane(m["node_repave_interval"].(int)) + if err != nil { + return mp, err + } + + } + return mp, nil }