Repository navigation
feat(binding-kafka): pass raw api request streams through the cache bindings - #3185
Merged
jfallows merged 5 commits intoNov 13, 2026
Conversation
…he cache bindings Add CacheApiIT with plain and version-negotiated api request streams through cache_client and cache_server, together and each on its own, reusing the existing application api scripts, plus the two single binding configurations and their schema validation. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv
…indings Register KIND_API_REQUEST in cache_client and cache_server with a pass-through factory that resolves the exit like the other cache pass-through streams and relays begin, data, end, abort, window and reset in both directions. Flush is relayed in both directions and challenge is relayed to the caller on the initial stream, so the version negotiation reaches the caller unchanged. Fixes #3183 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv
An accept stanza takes option zilla:affinity, but the server channel config never stored the value and an accepted channel never inherited it, so the expected-affinity check on an accepted stream never ran and a script expecting an affinity passed with any affinity. Store the option on the server channel config and copy it to each accepted channel, as the other accept options are. SimplexIT.shouldHandshakeWithAffinity matches on both sides and passes before and after. With the server expecting a different affinity than the client sends it passed before this change and fails after it, the client never reaching connected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv
…api request stream Run the plain api request with an affinity on the caller and the same affinity expected at the exit through cache_client and cache_server together and each on its own, plus the spec level scenario. These fail while the cache bindings open the exit stream with a different affinity than the caller sent. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv
…request stream Open the exit stream with the affinity of the caller's stream, as the offset fetch pass-through does, so the stream selects the same connection at the exit as it would on the client binding directly. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv
jfallows
force-pushed
the
fix/3183-kafka-cache-api-passthrough
branch
from
November 13, 2026 02:16
b4ee4e5 to
b3bc439
Compare
jfallows
changed the base branch from
develop
to
fix/3173-kafka-offset-delete-codec
November 13, 2026 02:17
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Raw Kafka API request streams (
KIND_API_REQUEST) were registered only by the kafkaclientbinding.cache_clientandcache_serverhad no entry for them, so a raw API request stream opened toward either cache binding was rejected, and the raw API streams could not be reached through the standardcache_client->cache_server->clienttopology.This adds
KafkaCacheApiFactory, registered forKIND_API_REQUESTin bothKafkaCacheClientFactoryandKafkaCacheServerFactory. It passes the stream through to the binding's exit without caching, filtering or interpreting the frames, so the stream behaves as if it had been opened on theclientbinding directly, including the version negotiation (the ApiVersions challenge and the flush that selects a version) and the affinity of the caller's stream. Streams of every other kind are unaffected. There is no change to binding configuration, route matching or the JSON schema.Design: #3183 (comment)
Stacked: this PR's base is
fix/3173-kafka-offset-delete-codec(headaacd3e6ee9), the last PR below it in a linear stack ondevelop. Nothing in the PRs below touches the cache bindings; the rebase onto it had no conflicts and no changes beyond replaying the commits.Commits (in this order)
dae290b35ftest(binding-kafka): failing api request pass-through tests (CacheApiIT, two single-binding configs, schema validation).1a0ace5a92feat(binding-kafka):KafkaCacheApiFactoryand its registration.5cfb983eaffix(engine): honor an accept-side affinity option in k3po zilla scripts (engine test extension only).cc422dfacctest(binding-kafka): failing affinity pass-through tests (scenariocreate.topics.v7.affinity, one spec IT method, threeCacheApiITmethods).b3bc439606fix(binding-kafka): pass the caller's affinity to the exit of an api request stream.Mirrored pattern
KafkaCacheInitProducerIdFactoryis the existing pass-through in the same module (one class used by both cache bindings, an app/net pair, exit resolved withbinding.resolve(authorization, null)).KafkaCacheApiFactoryis built on it. Flush is relayed the wayKafkaCacheGroupFactoryrelays it. The caller's affinity is passed on the wayKafkaCacheOffsetFetchFactorydoes: read from the caller's BEGIN and given to the exit stream.Part to review: the challenge relay
This is the one new pattern. No cache factory relayed CHALLENGE before. It is relayed the same way as FLUSH, in the direction the
clientbinding already uses: from the exit toward the caller, on the initial stream id (KafkaClientApiFactory.doAppChallengewrites it there). FLUSH (carrying the chosen version) travels the other way, from the caller to the exit on the initial stream id. A reply FLUSH from the exit is relayed to the caller on the reply stream id. This keeps the negotiation exactly as theclientbinding exposes it.What the cache does and does not interpret
The cache only relays frames. It does not parse request or response bodies, ApiVersions messages, API keys, versions, error codes or the challenge and flush extensions; it copies the extension bytes as they are. All protocol behaviour below belongs to the
clientbinding and to the caller, not to this change.Affinity
The
clientbinding keys its broker connection by the affinity of the stream (clientsByAffinity), and the Kafka guide says supported versions are valid only for the connection they were obtained on. The first version of this PR opened the exit stream with affinity 0, so every API stream shared one connection whatever affinity the caller chose. The caller's affinity now reaches the exit, in the cache bindings alone and in the chain.Engine change (commit
5cfb983eaf)In the engine's k3po zilla extension, an
acceptstanza takesoption zilla:affinity, but the server channel config never stored the value (DefaultZillaServerChannelConfig.setOption0did not map it) and an accepted channel never inherited it (ZillaPartitiondid not copy it), so the expected-affinity check on an accepted stream never ran and a script expecting an affinity passed with any affinity. The change stores the option on the server channel config and copies it to each accepted channel, as the other accept options are. It is needed here because the affinity scenario below would otherwise pass whatever the exit stream's affinity is.Scope of the change: I checked every
.rptfile for the option inside anacceptstanza. There are exactly two: the engine's ownhandshake.affinity/server.rpt(matching on both sides, still passes) and the newcreate.topics.v7.affinity/server.rpt. No other script in the repository is affected. This is a change to the engine's test extension, which is shared by every module's ITs; please review it as such.Protocol text read
Read by me from the Apache Kafka source and guide (fetched with curl on 2026-11-13). The
trunkfiles aretrunkat that time, not a tagged release.clients/src/main/resources/common/message/ApiVersionsRequest.json: API key 18; valid versions 0-5; versions 0 through 2 are the same; version 3 is the first flexible version; request header version 1 for v0-2 and 2 for v3+..../ApiVersionsResponse.json:ErrorCode(int16);ApiKeys[]withApiKey,MinVersionandMaxVersion(int16, from v0);ThrottleTimeMsfrom v1; the response always uses a v0 header; a comment that, starting from Apache Kafka 2.4 (KIP-511),ApiKeysis populated with the supported versions of ApiVersionsRequest when an UNSUPPORTED_VERSION error is returned..../RequestHeader.json(RequestApiKey,RequestApiVersion,CorrelationId,ClientIdwith the old two-byte length prefix) and.../ResponseHeader.json(CorrelationId).UNSUPPORTED_VERSIONis 35), and the API key table (ApiVersionsis 18).What the text says that bears on this change:
Not read: the message definitions of any API other than ApiVersions and the headers, and the texts of KIP-35 and KIP-511 (only cited by the sources above).
Does the relayed negotiation match that text
From the code of
KafkaClientApiFactory(not changed here): the client binding sends ApiVersions with version 0 (API_VERSIONS_API_VERSION = 0), recordsMinVersionandMaxVersionperApiKeyfrom the response, and challenges the caller with the range for the stream's API key (apiChallengeversions min and max). The caller answers with a flush carrying the chosen version, and the binding rejects an unsupported choice (apiVersionSupported, reset withERROR_UNSUPPORTED_VERSION). That is the guide's "choose the highest version supported by both", performed by the caller. The cache bindings relay the challenge and the flush unchanged. I did not run an ApiVersions exchange against a real broker.Fixes #3183
Test evidence
Tests are written first. The scenarios reuse the existing
application/apiscriptscreate.topics.v7(plain) andapi.challenge.negotiate(challenge, then flush with version 7, then request and response), asCacheGroupITreuses application scripts, plus one new paircreate.topics.v7.affinity(the plain request withzilla:affinity 0xb1on the caller and the same expected at the exit).CacheApiITruns each of them throughcache_clientandcache_servertogether, throughcache_clientalone and throughcache_serveralone; the spec-level scenarios keep their spec ITs (KafkaCreateTopicsIT,KafkaApiChallengeIT).Run on this base (
aacd3e6ee9), one commit state at a time, with unchanged production code each time:dae290b35f(tests only): all 6CacheApiITmethods fail. Each fails with a script mismatch atconnectedbecause the cache rejects the stream, then times out on the rerun.1a0ace5a92(implementation): all 6 pass.cc422dfacc(engine harness and affinity tests, factory not yet fixed): the 3 affinity methods fail, again atconnected, with the exit not accepting a stream whose affinity differs from the one expected; the other 6 pass. I saw the failures but did not read a message naming the affinity refusal.b3bc439606(head): all 9 pass.Controls run on the previous base (
developat 5556779), not re-run on this one:SimplexIT.shouldHandshakeWithAffinitywith the server expecting...b2Land the client sending...b1L, and the new kafka scenario at spec level with0xb2and with1L.ZillaPartitioncopy (no option mapping), the mismatch still passed.Verification of the head,
clean verifyofruntime/engine,specs/binding-kafka.specandruntime/binding-kafkatogether, with checkstyle (0 violations) and license checks on and the build cache skipped, after installing the upstream modules with-Dskip.checks=true: BUILD SUCCESS in 3 min 45 s.runtime/engine: unit tests 310 run, 0 failures, 1 skipped; ITs 264 run, 0 failures, 13 skipped.specs/binding-kafka.spec: unit tests 226 run, 0 failures; ITs 467 run, 0 failures, 12 skipped.runtime/binding-kafka: unit tests 229 run, 0 failures; ITs 442 run, 0 failures, 67 skipped.Full reactor, run once on the same five commits before the rebase onto this base (so on the
developbase),./mvnw -B -fae clean install -Dmaven.build.cache.skipCache=truefrom the repository root: 40 min 29 s, 216 modules succeeded and one failed,incubator/command-dump, whose ITs need Docker (26 of 27 errored with "Could not find a valid Docker environment" because I had not started the daemon) and which leftcloud/docker-imageandcloud/helm-chartskipped. After startingdockerd, resuming from that module (-rf :command-dump) gave BUILD SUCCESS in 1 min 28 s:command-dump27 run, 0 failures, 1 skipped, and the cloud modules built. No test failed on an assertion in the reactor.What I did not run
develop.Not delivered / follow-ups
.rptscripts for the plain and negotiated shapes: the two existing scripts cover them. There is no script for an unsupported-version reset through the cache, so the reset mapping is exercised only by the relay code, not by a dedicated scenario.CacheApiITis a new class, following the per-stream-kind convention ofCacheGroupIT,CacheConsumerITand the otherCache*ITclasses. There is no general cache IT class to add the methods to.KafkaCacheApiFactoryadvances its caller-sideinitialSeqbysequence + reserved. The factory it was built on setsinitialSeq = sequence, and so doKafkaCacheGroupFactory,KafkaCacheOffsetFetchFactoryandKafkaCacheOffsetCommitFactory. In the new factory that trippedacknowledge <= sequencewhen acache_clientfed acache_serverand the exit acked the 110-byte request: the window it relays carries the exit's acknowledge but the stale sequence. Whether the same line is wrong in the other factories is not established: I only observed the failure in the new factory.KafkaCacheInitProducerIdFactoryhas no cache IT at all, and the group and offset ITs pass throughcache.yamlas they are. Those factories are not changed here; a failing test comes first in any follow-up.KafkaCacheGroupFactoryandKafkaCacheInitProducerIdFactoryopen their exit streams with affinity 0 whileKafkaCacheOffsetFetchFactorypasses the caller's. Not changed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoW89puKTRXz38vabmv