Skip to content

Support Kafka 2.6.x brokers (e.g. Alibaba Cloud managed Kafka) in the Watermill/Sarama driver #5366

Description

@caelaxie

Context & Problem

We are deploying OpenMeter on Kubernetes via the Helm chart (kafka.enabled: false, pointing config.ingest.kafka and config.sink.kafka at an external managed Kafka cluster) on Alibaba Cloud (Aliyun).

Aliyun's managed Kafka service (ApsaraMQ for Kafka) currently offers Apache Kafka 2.6.2 as its highest supported broker version, with no near-term upgrade path to 2.8+ or 3.x.

When deploying OpenMeter against a Kafka 2.6.2 broker, the confluent-kafka-go (librdkafka) components work out of the box, but the Watermill event bus (IBM/sarama) fails to connect on startup:

kafka: client has run out of available brokers to talk to: EOF

Root Cause

OpenMeter uses two Kafka client libraries:

  1. confluent-kafka-go/v2 (librdkafka v2.16.0) (used for ingest, sink-worker, and topic provisioning):

    • Uses api.version.request = true by default and dynamically negotiates protocol versions with the 2.6.2 broker.
    • Consumer features used by OpenMeter (cooperative-sticky assignment added in Kafka 2.4, static membership group.instance.id added in Kafka 2.3) are natively supported by Kafka 2.6.2.
  2. IBM/sarama v1.61.1 (used via watermill-kafka/v3 in openmeter/watermill/driver/kafka/broker.go):

    • createKafkaConfig calls sarama.NewConfig(), which defaults config.Version to sarama.V2_8_0_0 (2.8.0.0), and sets config.ApiVersionsRequest = false.
    • At V2_8_0_0, Sarama sends protocol request versions introduced in Kafka 2.7/2.8 (such as MetadataRequest v10, ProduceRequest v9, FetchRequest v12, and ListOffsetsRequest v6).
    • A Kafka 2.6.2 broker only supports up to Metadata v9, Produce v8, Fetch v11, and ListOffsets v5, causing the broker to reject the requests.

Evidence & Local Verification

We tested OpenMeter against a local Apache Kafka 2.6.2 broker (kafka_2.13-2.6.2):

  • With the current default (sarama.V2_8_0_0): sarama.NewClient immediately fails with kafka: client has run out of available brokers to talk to: EOF.
  • With config.Version = sarama.V2_6_2_0 in openmeter/watermill/driver/kafka/broker.go:
    • TopicProvisioner (confluent-kafka-go AdminClient) creates topics as expected.
    • Watermill NewPublisher and NewSubscriber (IBM/sarama) connect, publish messages with partition keys, join consumer groups, and consume/ack messages without error.
    • Ingest producer and sink-worker consumer (confluent-kafka-go with cooperative-sticky) produce and consume events end-to-end.
    • Note: sarama.V2_6_2_0 (Metadata v9, Produce v8, Fetch v11) is also above the Kafka 4.0 minimum client protocol baseline (KIP-896 requires Kafka 2.1+), so it remains compatible with Kafka 3.x and 4.x brokers.

Proposed Solution

Either of the following (or both) would unblock Helm deployments against Kafka 2.6.2:

  1. Lower the default Sarama protocol version in openmeter/watermill/driver/kafka/broker.go:

    func (o *BrokerOptions) createKafkaConfig(role string) (*sarama.Config, error) {
        config := sarama.NewConfig()
        config.Version = sarama.V2_6_2_0

    Since OpenMeter's Watermill driver does not use any Kafka 2.7/2.8-specific protocol fields, V2_6_2_0 works across Kafka 2.6.2 through 4.x.

  2. Or make the Kafka protocol version configurable in KafkaConfiguration (e.g. ingest.kafka.version in config.yaml / Helm values.yaml under config.ingest.kafka.version), parsed via sarama.ParseKafkaVersion(...) and defaulting to sarama.V2_8_0_0 (or sarama.V2_6_2_0).

Activity

  1. ToniAdreal commented on Oct 28, 2026

    @ToniAdreal

    Verified the diagnosis against current main, and it holds end to end — with two scoping notes that may help pick between the two proposed fixes:

    1. Single choke point. openmeter/watermill/driver/kafka/broker.go:createKafkaConfig is the only sarama.NewConfig() call site I found in the repo, and both the Watermill publisher (publisher.go:33) and subscriber (subscriber.go:46) go through it, so pinning the version there covers both directions. It never sets config.Version, so it inherits Sarama's DefaultVersion = V2_8_0_0 (IBM/sarama utils.go, go.mod pins v1.61.1).

    2. The disabled negotiation is the second half of the failure, not just the high default. createKafkaConfig sets config.ApiVersionsRequest = false (with a comment about ApiVersionsRequest V3 errors flooding logs), so the client cannot discover the broker is 2.6 and downgrade on its own — the configured version becomes a hard ceiling. That also means re-enabling negotiation is not a clean alternative here; lowering the version is.

    3. Option 2 (a configurable version) is a bigger change than it looks: there is no version field anywhere in the Kafka config plumbing — pkg/kafka/config.go's CommonConfigParams has no Version, and app/config/kafka.go's ConfigureKafkaConfiguration sets no kafka.version default — so it needs a new field plus a viper default plus plumbing into BrokerOptions, whereas option 1 is a one-line change in createKafkaConfig. If the goal is just to unblock 2.6 brokers, I'd start with option 1 (V2_6_2_0, which Sarama defines) and treat configurability as a follow-up.

    No blocker from me on option 1. (Verification here is source-level against current main; the Kafka 2.6 broker run in the issue body is the reporter's, not mine.)

  2. mvanhorn commented on Nov 13, 2026

    @mvanhorn

    The shared Sarama config never set a protocol version, so it kept the library default of 2.8.0 and sent request versions a 2.6.2 broker rejects. ApiVersions negotiation is turned off, so the client cannot discover the broker and step down; the configured version is a hard ceiling the broker must accept.

    createKafkaConfig now pins the Sarama protocol version to 2.6.2, which that broker supports and which 3.x and 4.x brokers still accept.

    #5513

  3. jedi-tal commented on Nov 16, 2026

    @jedi-tal

    Same root cause breaks Redpanda too, and pinning 2.6.2 (#5513) wouldn't fix it there

    We hit this running OpenMeter v1.0.0-beta.236 against Redpanda v26.2.6 as the Kafka API. It matches this issue: the confluent-kafka-go components (ingest, sink-worker) work, because librdkafka negotiates versions. The Watermill/Sarama consumers (balance-worker, notification-service, billing-worker) never join their consumer group:

    • Redpanda logs Error while processing request from <client> - Unsupported version 7 for join_group API and closes the connection: about 31k rejections in 4 hours.
    • The workers log Group consume error with EOF several times a second. In our deployment the retry loop also grew the workers' memory steadily until they were OOM-killed.

    Redpanda supports join_group 0-6, sync_group 0-4 and produce 0-8, per src/v/kafka/protocol/schemata/*_request.json, the same on dev.

    This is what Sarama sends for each configured Version. With config.ApiVersionsRequest = false these are hard ceilings:

    Request V2_8_0_0 (current default) V2_6_2_0 (#5513) V2_4_0_0
    JoinGroup (NewJoinGroupRequest) v7 v7 v6
    SyncGroup (consumerGroup.syncGroupRequest) v5 v5 v4
    Produce (produceSet.buildRequest) v9 v8 v8

    So with #5513 merged, Redpanda would still reject JoinGroup v7, and SyncGroup v5 right after it. At V2_4_0_0 every request is within Redpanda's ranges. We only observed the JoinGroup rejection; the consumers never get further. The rest of the table comes from the Sarama source.

    Two ways to cover both Kafka 2.6.x brokers and Redpanda:

    1. Make the Sarama protocol version configurable, for example a setting parsed with sarama.ParseKafkaVersion, defaulting to whatever feat(kafka): speak Kafka 2.6.2 in the Watermill Sarama driver #5513 settles on. Redpanda users would set 2.4.0.
    2. Re-enable ApiVersionsRequest. Sarama then clamps each request to the broker's advertised range (restrictApiVersion in api_versions.go, called from the broker's send path), which works for any broker without picking a version. chore: filter out sarama autonegotation issue #3546 turned it off to stop the ApiVersionsRequest errors flooding the logs, so that noise would need handling another way.

    Happy to test either against Redpanda.

  4. ToniAdreal commented on Nov 17, 2026

    @ToniAdreal

    Verified @jedi-tal's table independently against the Sarama version pinned in this repo's go.mod (IBM/sarama v1.61.1) and Redpanda's schemata on dev. All three rows check out.

    JoinGroup: NewJoinGroupRequest in sarama join_group_request.go sends v7 at 2.5.0 and above, v6 at 2.4.0. So 2.8.0 and 2.6.2 both send v7, 2.4.0 sends v6.

    SyncGroup: consumer_group.go syncGroupRequest sends v5 at 2.5.0 and above, v4 at 2.4.0. So 2.8.0 and 2.6.2 both send v5, 2.4.0 sends v4.

    Produce: produce_set.go buildRequest sends v9 at 2.8.0 and above, v8 at 2.4.0 and above. So 2.8.0 sends v9, 2.6.2 and 2.4.0 both send v8.

    Redpanda's ceilings from src/v/kafka/protocol/schemata/*_request.json (validVersions on dev) are join_group 0-6, sync_group 0-4, produce 0-8, matching the report.

    So the conclusion holds. After #5513 pins the client to 2.6.2, JoinGroup still goes out as v7 and SyncGroup as v5, both above Redpanda's ceilings. At 2.4.0 all three land inside Redpanda's ranges (v6/v4/v8) and inside what a Kafka 2.6.2 broker accepts, since its maxima are v7/v5/v8.

    On the two fix shapes: option 1 (configurable version, defaulting to #5513's 2.6.2) is the smaller change, and it keeps the #3546 decision to leave ApiVersionsRequest off. Option 2 would reopen the log flooding #3546 was closed to stop. I verified the numbers only, no live broker run, and I have no Redpanda deployment to test against. Happy to re-check either shape against the Sarama source if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions