Skip to content

list_topics / list_users fail with 404 on Strimzi ≤ 0.40.0 (v1beta2 vs v1 API version mismatch) #1

@bmishkin

Description

@bmishkin

Bug

list_topics, list_users, health_check, and other tools that operate on KafkaTopic/KafkaUser resources return a 404:

Error listing topics: Failure executing: GET at:
https://<cluster>/apis/kafka.strimzi.io/v1/namespaces/kafka/kafkatopics.
Message: Not Found.

Root cause

The Strimzi API library (io.strimzi:api:0.49.1) annotates KafkaTopic and KafkaUser with @Version("v1"). The Fabric8 client derives the API path from this annotation, so it calls kafka.strimzi.io/v1.

However, clusters running Strimzi operator 0.40.0 and earlier only register kafka.strimzi.io/v1beta2v1 was not yet available in that operator release:

$ kubectl api-resources | grep kafkatopic
kafkatopics   kt   kafka.strimzi.io/v1beta2   true   KafkaTopic

Tools that operate on Kafka cluster CRDs (which were already v1) work fine — so list_kafkas, get_kafka_status, etc. all succeed. Only resources still on v1beta2 are affected.

Proposed fix

Detect the available served versions for KafkaTopic at startup using the K8s API discovery endpoint, and configure StrimziResourceRepository to use the correct version:

// In StrimziMcpServer.java
private static String detectKafkaStrimziApiVersion(KubernetesClient client) {
    try {
        var resources = client.getApiResources("kafka.strimzi.io/v1");
        if (resources != null && resources.getResources() != null &&
            resources.getResources().stream().anyMatch(r -> "kafkatopics".equals(r.getName()))) {
            return "v1";
        }
    } catch (Exception ignored) {}
    return "v1beta2";
}

Pass the detected version into the tool factories so StrimziResourceRepository uses an explicit-version call (e.g. via ResourceDefinitionContext) when v1 is unavailable. Alternatively, accept the API version as an environment variable/config flag to let operators override it.

Environment

  • Strimzi operator: 0.40.0
  • Strimzi API lib in pom.xml: 0.49.1
  • Kubernetes: AWS EKS (us-east-1)
  • Affected tools: list_topics, list_users, health_check, and any tool using KafkaTopic/KafkaUser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions