Skip to content

Commit

Permalink
PLT-695: Added additional meta attribute support for libvirt, edge-na…
Browse files Browse the repository at this point in the history
…tive, edge-vsphere.
  • Loading branch information
nikchern committed Sep 22, 2023
1 parent 764987e commit f2a963d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spectrocloud/resource_cluster_edge_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
21 changes: 21 additions & 0 deletions spectrocloud/resource_cluster_edge_vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
21 changes: 21 additions & 0 deletions spectrocloud/resource_cluster_libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit f2a963d

Please sign in to comment.