strimzi-kafka-operator icon indicating copy to clipboard operation
strimzi-kafka-operator copied to clipboard

Make it easier to wait for custom resource readiness when using the Strimzi `api` module

Open scholzj opened this issue 1 year ago • 0 comments

When using the Strimzi api module from other parts of Strimzi or from outside applications just using it as an dependency, one of the common tasks is to wait for the custom resource to get ready. This can be easily done fairly easily directly in the code. For example for a Kafka cluster, it would be:

Crds.kafkaOperation(client).inNamespace(NAMESPACE).withName(NAME).waitUntilCondition(k -> {
    if (k.getStatus() != null && k.getStatus().getConditions() != null) {
        return updatedKafka.getMetadata().getGeneration() == k.getStatus().getObservedGeneration()
                && k.getStatus().getConditions().stream().anyMatch(c -> "Ready".equals(c.getType()) && "True".equals(c.getStatus()));
    } else {
        return false;
    }
}, 5, TimeUnit.MINUTES);

But it might be nicer to have this directly in the api module itself to simplify the application code and allow the users of the api module to call for example only something like:

Crds.kafkaOperation(client).inNamespace(NAMESPACE).withName(NAME).waitUntilCondition(Kafka.readyCondition(), 5, TimeUnit.MINUTES);

This will make it this code part of Strimzi so we can improve it if something changes in the Strimzi itself. It will be also easier to use for users. We can also cover different states (e.g. the KafkaRebalance CR can support different conditions for different states such as ProposalReady etc.)

scholzj avatar Aug 02 '22 10:08 scholzj

Triaged on 25.8.2022: Should be kept and implemented. Might be a good first issue.

scholzj avatar Aug 25 '22 08:08 scholzj