use of org.bf2.operator.clients.canary.CanaryService in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class CanaryTest method createCanaryService.
@Test
void createCanaryService() throws Exception {
ManagedKafka mk = new ManagedKafkaBuilder().withNewMetadata().withNamespace("test").withName("test-mk").endMetadata().withSpec(new ManagedKafkaSpecBuilder().withNewVersions().withKafka("2.6.0").endVersions().withNewEndpoint().withBootstrapServerHost("test-mk-kafka-bootstrap").endEndpoint().build()).build();
Service canaryService = canary.serviceFrom(mk, null);
server.getClient().services().create(canaryService);
assertNotNull(server.getClient().services().inNamespace(canaryService.getMetadata().getNamespace()).withName(canaryService.getMetadata().getName()).get());
KafkaClusterTest.diffToExpected(canaryService, "/expected/canary-service.yml");
}
use of org.bf2.operator.clients.canary.CanaryService in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaManager method doKafkaUpgradeStabilityCheck.
/**
* Scheduled job to execute the Kafka stability check
*
* @param managedKafka ManagedKafka instance
*/
void doKafkaUpgradeStabilityCheck(ManagedKafka managedKafka) {
log.infof("[%s/%s] Kafka upgrade stability check", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName());
CanaryService canaryService = RestClientBuilder.newBuilder().baseUri(URI.create("http://" + AbstractCanary.canaryName(managedKafka) + "." + managedKafka.getMetadata().getNamespace() + ":8080")).connectTimeout(10, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).build(CanaryService.class);
try {
Status status = canaryService.getStatus();
log.infof("[%s/%s] Canary status: timeWindow %d - percentage %d", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), status.getConsuming().getTimeWindow(), status.getConsuming().getPercentage());
if (status.getConsuming().getPercentage() > consumingPercentageThreshold) {
log.debugf("[%s/%s] Remove Kafka upgrade start/end annotations", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName());
managedKafkaClient.inNamespace(managedKafka.getMetadata().getNamespace()).withName(managedKafka.getMetadata().getName()).edit(mk -> new ManagedKafkaBuilder(mk).editMetadata().removeFromAnnotations(KAFKA_UPGRADE_START_TIMESTAMP_ANNOTATION).removeFromAnnotations(KAFKA_UPGRADE_END_TIMESTAMP_ANNOTATION).endMetadata().build());
} else {
log.warnf("[%s/%s] Reported consuming percentage %d less than %d threshold", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), status.getConsuming().getPercentage(), consumingPercentageThreshold);
managedKafkaClient.inNamespace(managedKafka.getMetadata().getNamespace()).withName(managedKafka.getMetadata().getName()).edit(mk -> new ManagedKafkaBuilder(mk).editMetadata().removeFromAnnotations(KAFKA_UPGRADE_END_TIMESTAMP_ANNOTATION).endMetadata().build());
}
// trigger a reconcile on the ManagedKafka instance to push checking if next step
// Kafka IBP upgrade is needed or another stability check
informerManager.resyncManagedKafka(managedKafka);
} catch (Exception e) {
log.errorf("[%s/%s] Error while checking Kafka upgrade stability", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), e);
}
}
Aggregations