use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaResourceType method readiness.
@Override
public Predicate<ManagedKafka> readiness(KubeClient client) {
AtomicInteger count = new AtomicInteger();
Set<String> messages = Collections.synchronizedSet(new LinkedHashSet<>());
return mk -> {
if (mk == null) {
throw new IllegalStateException("ManagedKafka is null");
}
ManagedKafkaCondition mkc = getCondition(mk.getStatus(), ManagedKafkaCondition.Type.Ready).orElse(null);
if (mkc == null) {
return false;
}
if (ManagedKafkaCondition.Status.True.name().equals(mkc.getStatus())) {
return true;
}
if (ManagedKafkaCondition.Reason.Error.name().equals(mkc.getReason())) {
if (messages.add(mkc.getMessage())) {
LOGGER.warn("ManagedKafka {} in error state {}", mk.getMetadata().getName(), mkc.getMessage());
}
// throw new IllegalStateException(String.format("ManagedKafka %s in error state %s", mk.getMetadata().getName(), mkc.getMessage()));
}
if (count.getAndIncrement() % 15 == 0) {
ListOptions opts = new ListOptionsBuilder().withFieldSelector("status.phase=Pending").build();
client.client().pods().inNamespace(mk.getMetadata().getNamespace()).withLabel("strimzi.io/cluster").list(opts).getItems().forEach(ManagedKafkaResourceType::checkUnschedulablePod);
}
return false;
};
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaManager method currentKafkaVersion.
/**
* Returns the current Kafka version for the Kafka instance
* It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
*
* @param managedKafka ManagedKafka instance
* @return current Kafka version for the Kafka instance
*/
public String currentKafkaVersion(ManagedKafka managedKafka) {
Kafka kafka = cachedKafka(managedKafka);
// on first time Kafka resource creation, we take the Kafka version from the ManagedKafka resource spec
String kafkaVersion = kafka != null ? kafka.getSpec().getKafka().getVersion() : managedKafka.getSpec().getVersions().getKafka();
log.debugf("[%s/%s] currentKafkaVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaVersion);
return kafkaVersion;
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaManager method currentKafkaLogMessageFormatVersion.
/**
* Returns the current Kafka log message format version for the Kafka instance
* It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
*
* @param managedKafka ManagedKafka instance
* @return current Kafka log message format version for the Kafka instance
*/
public String currentKafkaLogMessageFormatVersion(ManagedKafka managedKafka) {
Kafka kafka = cachedKafka(managedKafka);
String kafkaLogMessageFormatVersion;
String current;
// on first time Kafka resource creation, we take the Kafka log message format version from the ManagedKafka resource spec
if (kafka != null) {
Object logMessageFormat = kafka.getSpec().getKafka().getConfig().get("log.message.format.version");
current = logMessageFormat != null ? logMessageFormat.toString() : kafka.getSpec().getKafka().getVersion();
} else {
current = managedKafka.getSpec().getVersions().getKafka();
}
kafkaLogMessageFormatVersion = AbstractKafkaCluster.getKafkaLogMessageFormatVersion(current);
log.debugf("[%s/%s] currentKafkaLogMessageFormatVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaLogMessageFormatVersion);
return kafkaLogMessageFormatVersion;
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaManager method currentKafkaIbpVersion.
/**
* Returns the current Kafka inter broker protocol version for the Kafka instance
* It comes directly from the Kafka custom resource or from the ManagedKafka in case of creation
*
* @param managedKafka ManagedKafka instance
* @return current Kafka inter broker protocol version for the Kafka instance
*/
public String currentKafkaIbpVersion(ManagedKafka managedKafka) {
Kafka kafka = cachedKafka(managedKafka);
String kafkaIbpVersion;
// on first time Kafka resource creation, we take the Kafka inter broker protocol version from the ManagedKafka resource spec
if (kafka != null) {
Object interBrokerProtocol = kafka.getSpec().getKafka().getConfig().get("inter.broker.protocol.version");
kafkaIbpVersion = interBrokerProtocol != null ? AbstractKafkaCluster.getKafkaIbpVersion(interBrokerProtocol.toString()) : AbstractKafkaCluster.getKafkaIbpVersion(kafka.getSpec().getKafka().getVersion());
} else {
kafkaIbpVersion = managedKafka.getSpec().getVersions().getKafkaIbp();
// dealing with ManagedKafka instances not having the IBP field specified
if (kafkaIbpVersion == null) {
kafkaIbpVersion = AbstractKafkaCluster.getKafkaIbpVersion(managedKafka.getSpec().getVersions().getKafka());
}
}
log.debugf("[%s/%s] currentKafkaIbpVersion = %s", managedKafka.getMetadata().getNamespace(), managedKafka.getMetadata().getName(), kafkaIbpVersion);
return kafkaIbpVersion;
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class OperatorST method testResizeAndCapacity.
@ParallelTest
void testResizeAndCapacity(ExtensionContext extensionContext) throws Exception {
String mkAppName = "mk-test-resize-capacity";
LOGGER.info("Create namespace");
resourceManager.addResource(extensionContext, new NamespaceBuilder().withNewMetadata().withName(mkAppName).endMetadata().build());
LOGGER.info("Create managedkafka");
ManagedKafka mk = ManagedKafkaResourceType.getDefault(mkAppName, mkAppName, null, latestStrimziVersion, latestKafkaVersion);
Quantity quantity = Quantity.parse("100Gi");
// for values below 270Gi, the logic will report a slightly larger values
Quantity reportedQuantity = Quantity.parse("103Gi");
mk.getSpec().getCapacity().setMaxDataRetentionSize(quantity);
mk = resourceManager.createResource(extensionContext, mk);
Resource<ManagedKafka> mkResource = kube.client().resources(ManagedKafka.class).inNamespace(mk.getMetadata().getNamespace()).withName(mk.getMetadata().getName());
assertEquals(reportedQuantity, mk.getStatus().getCapacity().getMaxDataRetentionSize());
LOGGER.info("Trying to shrink");
mk.getSpec().getCapacity().setMaxDataRetentionSize(Quantity.parse("50Gi"));
mk = mkResource.createOrReplace(mk);
String currentVersion = mk.getMetadata().getResourceVersion();
// wait until the status is updated
mk = mkResource.waitUntilCondition(m -> !Objects.equals(currentVersion, m.getMetadata().getResourceVersion()), 2, TimeUnit.MINUTES);
// should be the same, as we can't resize down
assertEquals(reportedQuantity, mk.getStatus().getCapacity().getMaxDataRetentionSize());
LOGGER.info("Trying to grow");
mk.getSpec().getCapacity().setMaxDataRetentionSize(Quantity.parse("200Gi"));
mk = mkResource.createOrReplace(mk);
// should grow - again the size is a little off
Quantity endReportedQuantity = Quantity.parse("202Gi");
mk = mkResource.waitUntilCondition(m -> endReportedQuantity.equals(m.getStatus().getCapacity().getMaxDataRetentionSize()), 5, TimeUnit.MINUTES);
}
Aggregations