CKS: Prevent etcd node start port number to coincide with k8s cluster start port numbers

This commit is contained in:
Pearl Dsilva 2024-05-29 19:42:27 +01:00 committed by nvazquez
parent 7cf7f1f1b8
commit 2eae6a92c8
No known key found for this signature in database
GPG Key ID: 656E1BCC8CB54F84
1 changed files with 13 additions and 0 deletions

View File

@ -308,6 +308,7 @@ import com.googlecode.ipv6.IPv6Network;
public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, Configurable {
public static final String PERACCOUNT = "peraccount";
public static final String PERZONE = "perzone";
public static final String CLUSTER_NODES_DEFAULT_START_SSH_PORT = "2222";
@Inject
EntityManager _entityMgr;
@ -644,6 +645,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
}
protected void validateConflictingConfigValue(final String configName, final String value) {
if (configName.equals("cloud.kubernetes.etcd.node.start.port")) {
if (value.equals(CLUSTER_NODES_DEFAULT_START_SSH_PORT)) {
String errorMessage = "This range is reserved for Kubernetes cluster nodes." +
"Please choose a value in a higher range would does not conflict with a kubernetes cluster deployed";
logger.error(errorMessage);
throw new InvalidParameterValueException(errorMessage);
}
}
}
@Override
public boolean start() {
@ -945,6 +957,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
validateIpAddressRelatedConfigValues(name, value);
validateConflictingConfigValue(name, value);
if (value == null) {
return _configDao.findByName(name);