KAFKA-12278; Ensure exposed api versions are consistent within listener scopes#10066
KAFKA-12278; Ensure exposed api versions are consistent within listener scopes#10066hachikuji wants to merge 7 commits intoapache:trunkfrom
Conversation
777a37a to
b02e044
Compare
There was a problem hiding this comment.
The network package is not meant to access requests, right? Could we make it work by changing the supplier to something more generic?
There was a problem hiding this comment.
Hmm.. Do you have any ideas? I guess I would say that the dependency is there regardless of how we choose to hide it since we have to go through ChannelBuilders to build the authenticator, and the authenticator does depend on the request APIs.
There was a problem hiding this comment.
I guess I would say that the dependency is there regardless of how we choose to hide it since we have to go through ChannelBuilders to build the authenticator, and the authenticator does depend on the request APIs.
Yeah, the API versions response is pretty special in the protocol. Fortunately or unfortunately, it's not treated as a generic response. I tried to think of some ways to avoid this dependency but they all ended up being kind of like obfuscation.
Could we make it work by changing the supplier to something more generic?
Maybe I'm misinterpreting the suggestion, but if we choose to make this a Supplier<AbstractResponse>, that's still in the requests package....
There was a problem hiding this comment.
I meant that you could introduce an interface that the response implements. That interface would live in the network package or in the common package.
There was a problem hiding this comment.
Hmm. Let's revisit this after 2.8.
b02e044 to
7660c70
Compare
b785983 to
49d73fd
Compare
| def apply( | ||
| listenerType: ListenerType, | ||
| config: KafkaConfig, | ||
| forwardingManager: Option[ForwardingManager], |
There was a problem hiding this comment.
I would really prefer not to have all this ForwardingManager stuff in here. The ControllerServer has been committed to trunk and does handle ENVELOPE_REQUEST so I think this is out of date.
It should be as simple as controllers handle envelope requests, brokers don't, right?
There was a problem hiding this comment.
The ForwardingManager is used by the broker. The reason we depend on it here is because of the need to intersect the controller api versions.
I agree with you about the envelope handling. I was planning to submit a follow-up to remove this logic from KafkaApis. As you said, only the controller needs to be able to handle the Envelope API. Doing so here, however, would add a significant diff.
|
pushed |
With KIP-500, we have more complex requirements on API accessibility. Previously all APIs were accessible on every listener exposed by the broker, but now that is no longer true. For example:
LeaderAndIsrandUpdateMetadata)DecommissionBrokerandDescribeQuorum)All of this means that we need more sophistication in how we expose APIs and keep them consistent with the
ApiVersionsAPI. Up to now, we have been working around this using thecontrollerOnlyflag insideApiKeys, but this is not rich enough to support all of the cases listed above.In this patch, we address this by problem by introducing a new
listenersfield to the request schema definitions. This field is an array of strings which indicate the listener types in which the API should be exposed. We currently support the following listener types:zkBroker: old brokerbroker: kip-500 brokercontroller: kip-500 controllerFor example, the
DecommissionBrokerAPI has the following listeners tag:This indicates that the API is only on the KIP-500 broker and controller (both are needed because the request will be sent by clients and forwarded to the controller).
The patch changes the generator so that the listener type definitions are added to
ApiMessageTypeand exposed through convenient helpers. At the same time, we have removed thecontrollerOnlyflag fromApiKeyssince now we can identify all controller APIs through the "controller" tag.The rest of the patch is dedicated to ensuring that the API listener type is properly set and that the APIs accordingly tagged are carried through to the
ApiVersionsResponse. We have created a newApiVersionManagerwhich encapsulates the creation of theApiVersionsResponsebased on the listener type. Additionally,SocketServeris modified to ensure the listener type of received requests before forwarding them to the request handler.We have also fixed a bug in the handling of the
ApiVersionsResponseprior to authentication. Previously a static response was sent, which means that changes to features would not get reflected. This also meant that the logic to ensure that only the intersection of version ranges supported by the controller would get exposed did not work. I think this is important because some clients rely on the initial pre-authenticatedApiVersionsresponse rather than doing a second round after authentication as the Java client does.One final cleanup note: I have removed the expectation that envelope requests are only allowed on "privileged" listeners. This made sense initially because we expected to use forwarding before the KIP-500 controller was available. That is not the case anymore and we expect the
EnvelopeAPI to only be exposed on the controller listener. I have nevertheless preserved the existing workarounds to allow verification of the forwarding behavior in integration testing.Committer Checklist (excluded from commit message)