CKS: Add external node to a CKS cluster deployed with etcd node(s) successfully

* CKS: Add external node to a CKS cluster deployed with etcd node(s) successfully

* simplify logic
This commit is contained in:
Pearl Dsilva 2024-08-01 11:26:50 -04:00 committed by nvazquez
parent 9905f07b6e
commit fe3efdbe57
No known key found for this signature in database
GPG Key ID: 656E1BCC8CB54F84
1 changed files with 3 additions and 1 deletions

View File

@ -388,6 +388,7 @@ public class KubernetesClusterActionWorker {
if (controlVm != null) {
return controlVm;
}
Long etcdNodeCount = kubernetesCluster.getEtcdNodeCount();
List<KubernetesClusterVmMapVO> clusterVMs = kubernetesClusterVmMapDao.listByClusterId(kubernetesCluster.getId());
if (CollectionUtils.isEmpty(clusterVMs)) {
logger.warn(String.format("Unable to retrieve VMs for Kubernetes cluster : %s", kubernetesCluster.getName()));
@ -398,7 +399,8 @@ public class KubernetesClusterActionWorker {
vmIds.add(vmMap.getVmId());
}
Collections.sort(vmIds);
return userVmDao.findById(vmIds.get(0));
int controlNodeIndex = Objects.nonNull(etcdNodeCount) ? etcdNodeCount.intValue() : 0;
return userVmDao.findById(vmIds.get(controlNodeIndex));
}
protected String getControlVmPrivateIp() {