use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class FeatureGatesTest method testDuplicateFeatureGateWithSameValue.
@ParallelTest
public void testDuplicateFeatureGateWithSameValue() {
InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> new FeatureGates("+ControlPlaneListener,+ControlPlaneListener"));
assertThat(e.getMessage(), containsString("Feature gate ControlPlaneListener is configured multiple times"));
}
use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class FeatureGatesTest method testKraftAndPodSetsDependenciesNotFulfilled.
@ParallelTest
public void testKraftAndPodSetsDependenciesNotFulfilled() {
InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> new FeatureGates("+UseKRaft,-UseStrimziPodSets"));
assertThat(e.getMessage(), containsString("The UseKRaft feature gate can be enabled only when the UseStrimziPodSets feature gate is enabled as well."));
}
use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class ClusterOperatorConfig method parseKafkaVersions.
private static KafkaVersion.Lookup parseKafkaVersions(String kafkaImages, String connectImages, String mirrorMakerImages, String mirrorMaker2Images) {
KafkaVersion.Lookup lookup = new KafkaVersion.Lookup(Util.parseMap(kafkaImages), Util.parseMap(connectImages), Util.parseMap(mirrorMakerImages), Util.parseMap(mirrorMaker2Images));
String image = "";
String envVar = "";
try {
image = "Kafka";
envVar = STRIMZI_KAFKA_IMAGES;
lookup.validateKafkaImages(lookup.supportedVersions());
image = "Kafka Connect";
envVar = STRIMZI_KAFKA_CONNECT_IMAGES;
lookup.validateKafkaConnectImages(lookup.supportedVersions());
image = "Kafka Mirror Maker";
envVar = STRIMZI_KAFKA_MIRROR_MAKER_IMAGES;
lookup.validateKafkaMirrorMakerImages(lookup.supportedVersions());
image = "Kafka Mirror Maker 2";
envVar = STRIMZI_KAFKA_MIRROR_MAKER_2_IMAGES;
lookup.validateKafkaMirrorMaker2Images(lookup.supportedVersionsForFeature("kafkaMirrorMaker2"));
} catch (NoImageException | UnsupportedVersionException e) {
throw new InvalidConfigurationException("Failed to parse default container image configuration for " + image + " from environment variable " + envVar, e);
}
return lookup;
}
use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class ClusterOperatorConfig method parseLabels.
/**
* Parse labels from String into the Labels format.
*
* @param vars Map with configuration variables
* @param configurationKey Key containing the string with labels
* @return Labels object with the Labels or null if no labels are configured
*/
private static Labels parseLabels(Map<String, String> vars, String configurationKey) {
String labelsString = vars.get(configurationKey);
Labels labels = null;
if (labelsString != null) {
try {
labels = Labels.fromString(labelsString);
} catch (Exception e) {
throw new InvalidConfigurationException("Failed to parse labels from " + configurationKey, e);
}
}
return labels;
}
use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class UserOperatorConfig method fromMap.
/**
* Loads configuration parameters from a related map
*
* @param map map from which loading configuration parameters
* @return Cluster Operator configuration instance
*/
@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:NPathComplexity" })
public static UserOperatorConfig fromMap(Map<String, String> map) {
String namespace = map.get(UserOperatorConfig.STRIMZI_NAMESPACE);
if (namespace == null || namespace.isEmpty()) {
throw new InvalidConfigurationException(UserOperatorConfig.STRIMZI_NAMESPACE + " cannot be null");
}
long reconciliationInterval = DEFAULT_FULL_RECONCILIATION_INTERVAL_MS;
String reconciliationIntervalEnvVar = map.get(UserOperatorConfig.STRIMZI_FULL_RECONCILIATION_INTERVAL_MS);
if (reconciliationIntervalEnvVar != null) {
reconciliationInterval = Long.parseLong(reconciliationIntervalEnvVar);
}
int scramPasswordLength = DEFAULT_SCRAM_SHA_PASSWORD_LENGTH;
String scramPasswordLengthEnvVar = map.get(UserOperatorConfig.STRIMZI_SCRAM_SHA_PASSWORD_LENGTH);
if (scramPasswordLengthEnvVar != null) {
scramPasswordLength = Integer.parseInt(scramPasswordLengthEnvVar);
}
String kafkaBootstrapServers = DEFAULT_KAFKA_BOOTSTRAP_SERVERS;
String kafkaBootstrapServersEnvVar = map.get(UserOperatorConfig.STRIMZI_KAFKA_BOOTSTRAP_SERVERS);
if (kafkaBootstrapServersEnvVar != null && !kafkaBootstrapServersEnvVar.isEmpty()) {
kafkaBootstrapServers = kafkaBootstrapServersEnvVar;
}
Labels labels;
try {
labels = Labels.fromString(map.get(STRIMZI_LABELS));
} catch (Exception e) {
throw new InvalidConfigurationException("Failed to parse labels from " + STRIMZI_LABELS, e);
}
String caCertSecretName = map.get(UserOperatorConfig.STRIMZI_CA_CERT_SECRET_NAME);
if (caCertSecretName == null || caCertSecretName.isEmpty()) {
throw new InvalidConfigurationException(UserOperatorConfig.STRIMZI_CA_CERT_SECRET_NAME + " cannot be null");
}
String caKeySecretName = map.get(UserOperatorConfig.STRIMZI_CA_KEY_SECRET_NAME);
if (caKeySecretName == null || caKeySecretName.isEmpty()) {
throw new InvalidConfigurationException(UserOperatorConfig.STRIMZI_CA_KEY_SECRET_NAME + " cannot be null");
}
String clusterCaCertSecretName = map.get(UserOperatorConfig.STRIMZI_CLUSTER_CA_CERT_SECRET_NAME);
String euoKeySecretName = map.get(UserOperatorConfig.STRIMZI_EO_KEY_SECRET_NAME);
String caNamespace = map.get(UserOperatorConfig.STRIMZI_CA_NAMESPACE);
if (caNamespace == null || caNamespace.isEmpty()) {
caNamespace = namespace;
}
String secretPrefix = map.get(UserOperatorConfig.STRIMZI_SECRET_PREFIX);
if (secretPrefix == null || secretPrefix.isEmpty()) {
secretPrefix = DEFAULT_SECRET_PREFIX;
}
boolean aclsAdminApiSupported = getBooleanProperty(map, UserOperatorConfig.STRIMZI_ACLS_ADMIN_API_SUPPORTED, UserOperatorConfig.DEFAULT_STRIMZI_ACLS_ADMIN_API_SUPPORTED);
boolean kraftEnabled = getBooleanProperty(map, UserOperatorConfig.STRIMZI_KRAFT_ENABLED, UserOperatorConfig.DEFAULT_STRIMZI_KRAFT_ENABLED);
int clientsCaValidityDays = getIntProperty(map, UserOperatorConfig.STRIMZI_CLIENTS_CA_VALIDITY, CertificateAuthority.DEFAULT_CERTS_VALIDITY_DAYS);
int clientsCaRenewalDays = getIntProperty(map, UserOperatorConfig.STRIMZI_CLIENTS_CA_RENEWAL, CertificateAuthority.DEFAULT_CERTS_RENEWAL_DAYS);
List<String> maintenanceWindows = parseMaintenanceTimeWindows(map.get(UserOperatorConfig.STRIMZI_MAINTENANCE_TIME_WINDOWS));
return new UserOperatorConfig(namespace, reconciliationInterval, kafkaBootstrapServers, labels, caCertSecretName, caKeySecretName, clusterCaCertSecretName, euoKeySecretName, caNamespace, secretPrefix, aclsAdminApiSupported, kraftEnabled, clientsCaValidityDays, clientsCaRenewalDays, scramPasswordLength, maintenanceWindows);
}
Aggregations