in ec/ecresource/deploymentresource/topology_dedicated_masters.go [197:238]
func countNodesInCluster(ctx context.Context, esPlan es.ElasticsearchTF, template models.DeploymentTemplateInfoV2) int32 {
nodesInDeployment := int32(0)
tierTopologyIds := []string{"hot_content", "coordinating", "warm", "cold", "frozen"}
for _, topologyId := range tierTopologyIds {
var rawTopology types.Object
switch topologyId {
case "hot_content":
rawTopology = esPlan.HotContentTier
case "coordinating":
rawTopology = esPlan.CoordinatingTier
case "warm":
rawTopology = esPlan.WarmTier
case "cold":
rawTopology = esPlan.ColdTier
case "frozen":
rawTopology = esPlan.FrozenTier
}
if rawTopology.IsNull() || rawTopology.IsUnknown() {
continue
}
size, zoneCount := getSizeAndZoneCount(ctx, topologyId, rawTopology, template)
// Calculate if there are >1 nodes in each zone:
// If the size is > the maximum size allowed in the zone, more nodes are added to reach the desired size.
instanceConfig := getTemplateInstanceConfiguration(template, topologyId)
maxSize := getMaxSize(instanceConfig)
var nodesPerZone int32
if size < maxSize || maxSize == 0 {
nodesPerZone = 1
} else {
nodesPerZone = size / maxSize
}
if size > 0 && zoneCount > 0 {
nodesInDeployment += zoneCount * nodesPerZone
}
}
return nodesInDeployment
}