use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi 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 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 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 by strimzi.
the class Session method adminClientProperties.
Properties adminClientProperties() {
Properties kafkaClientProps = new Properties();
kafkaClientProps.setProperty(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, config.get(Config.KAFKA_BOOTSTRAP_SERVERS));
kafkaClientProps.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, config.get(Config.APPLICATION_ID));
String securityProtocol = config.get(Config.SECURITY_PROTOCOL);
boolean tlsEnabled = Boolean.parseBoolean(config.get(Config.TLS_ENABLED));
if (tlsEnabled && !securityProtocol.isEmpty()) {
if (!securityProtocol.equals("SSL") && !securityProtocol.equals("SASL_SSL")) {
throw new InvalidConfigurationException("TLS is enabled but the security protocol does not match SSL or SASL_SSL");
}
}
if (!securityProtocol.isEmpty()) {
kafkaClientProps.setProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, securityProtocol);
} else if (tlsEnabled) {
kafkaClientProps.setProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, "SSL");
} else {
kafkaClientProps.setProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG, "PLAINTEXT");
}
if (securityProtocol.equals("SASL_SSL") || securityProtocol.equals("SSL") || tlsEnabled) {
kafkaClientProps.setProperty(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, config.get(Config.TLS_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM));
if (!config.get(Config.TLS_TRUSTSTORE_LOCATION).isEmpty()) {
kafkaClientProps.setProperty(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, config.get(Config.TLS_TRUSTSTORE_LOCATION));
}
if (!config.get(Config.TLS_TRUSTSTORE_PASSWORD).isEmpty()) {
if (config.get(Config.TLS_TRUSTSTORE_LOCATION).isEmpty()) {
throw new InvalidConfigurationException("TLS_TRUSTSTORE_PASSWORD was supplied but TLS_TRUSTSTORE_LOCATION was not supplied");
}
kafkaClientProps.setProperty(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, config.get(Config.TLS_TRUSTSTORE_PASSWORD));
}
if (!config.get(Config.TLS_KEYSTORE_LOCATION).isEmpty() && !config.get(Config.TLS_KEYSTORE_PASSWORD).isEmpty()) {
kafkaClientProps.setProperty(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, config.get(Config.TLS_KEYSTORE_LOCATION));
kafkaClientProps.setProperty(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, config.get(Config.TLS_KEYSTORE_PASSWORD));
}
}
if (Boolean.parseBoolean(config.get(Config.SASL_ENABLED))) {
setSaslConfigs(kafkaClientProps);
}
return kafkaClientProps;
}
use of io.strimzi.operator.common.InvalidConfigurationException in project strimzi-kafka-operator by strimzi.
the class ClusterOperatorConfigTest method testConfigParsingWithMissingEnvVar.
@Test
public void testConfigParsingWithMissingEnvVar() {
Map<String, String> envVars = new HashMap<>(5);
envVars.put(ClusterOperatorConfig.STRIMZI_KAFKA_IMAGES, KafkaVersionTestUtils.getKafkaImagesEnvVarString());
envVars.put(ClusterOperatorConfig.STRIMZI_KAFKA_CONNECT_IMAGES, KafkaVersionTestUtils.getKafkaConnectImagesEnvVarString());
envVars.put(ClusterOperatorConfig.STRIMZI_KAFKA_MIRROR_MAKER_IMAGES, KafkaVersionTestUtils.getKafkaMirrorMakerImagesEnvVarString());
envVars.put(ClusterOperatorConfig.STRIMZI_KAFKA_MIRROR_MAKER_2_IMAGES, KafkaVersionTestUtils.getKafkaMirrorMaker2ImagesEnvVarString());
for (Map.Entry<String, String> envVar : envVars.entrySet()) {
Map<String, String> editedEnvVars = new HashMap<>(envVars);
editedEnvVars.remove(envVar.getKey());
InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> ClusterOperatorConfig.fromMap(editedEnvVars));
assertThat(e.getMessage(), containsString(envVar.getKey()));
}
}
Aggregations