Repository navigation
[Server] Forward pluggable components through the one Armeria API port - #2036
Closed
s-maling-celonis wants to merge 4 commits into
Closed
s-maling-celonis wants to merge 4 commits into
s-maling-celonis wants to merge 4 commits into
Conversation
…L transcoder The launcher ran a Vert.x verticle on the client port that forwarded every request over HTTP/1.1 to Armeria on port + 1. Its only rewrite turned Iceberg's %1F nested-namespace separator into a period. Unity Catalog has no nested namespaces, so that rewrite only changed which error a client got for a name it could never resolve. Removing it means one listener, one event-loop stack, no second connection pool to keep sized to the JDBC pool, and no Vert.x and Netty 4.1 dependency line next to Armeria's Netty 4.2. - main binds Armeria to the -p port instead of port + 1, and closes the server if it cannot start. - The API port binds all interfaces, since clients now connect to it directly. The loopback bind existed only because the transcoder sat in front. - A %1F namespace now reaches the Iceberg service as-is and is reported as a missing namespace (404) instead of a bad request. - The http_server_requests_total hostname_pattern label now names the -p port (*:8080 by default) instead of port + 1 (*:8081). Signed-off-by: s-maling-celonis <[email protected]>
BaseServerTest picks two free ports with ServerSocket(0) and closes them before the server binds, so another process can take one in between. CI hit this as a ServerPortBindException in AuthServiceAllowlistTest. Now that the API port binds all interfaces instead of loopback, it can collide with more sockets. Retry the start with fresh ports, up to three attempts, when the cause is a ServerPortBindException. Any other start failure is thrown as before. Signed-off-by: s-maling-celonis <[email protected]>
Proof of concept for keeping one public port without the Vert.x transcoder. A component that runs its own listener, such as the embedded OpenSharing server proposed in unitycatalog#1825, binds to loopback, and ArmeriaServerBuilder#forward routes its path prefix to it from the API port. Every other path is still served by Armeria directly. ArmeriaForwardTest starts a separate server on loopback and checks that a request through the API port reaches it with method, path, query, auth header and body unchanged; that its status and headers come back; that UC routes are not forwarded; and that an unreachable target is reported as a server error. Signed-off-by: s-maling-celonis <[email protected]>
…ponents UnityCatalogServer.Builder#forward(pathPrefix, target) registers each forward on the API virtual host, alongside the UC services, so a component on its own loopback listener is reached through the one public port. UnityCatalogServerForwardTest starts a component on loopback next to a full UnityCatalogServer with authorization enabled, and checks through the API port that the component answers under its prefix while UC's own API still requires authentication. Signed-off-by: s-maling-celonis <[email protected]>
3 of 4 tasks
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.
PR Checklist
docsis updatedDraft, proof of concept. Stacked on #1979. Until #1979 merges, this diff includes its commits. The change here is the last two commits,
be4b6d0fand8144c5dc(+276 lines, about 40 of them non-test).Description of changes
In #1979, @yili-db asked to keep the Vert.x URL transcoder because it can serve pluggable components, such as the embedded OpenSharing server proposed in #1825, through one public port. This PR shows Armeria can do that itself, without proxying every UC request through Vert.x.
A component runs its own listener on loopback. UC forwards its path prefix from the API port, and Armeria keeps serving every other path directly:
This change:
ArmeriaServerBuilder#forward(pathPrefix, target): registers a handler forpathPrefixon the API virtual host that sends the request, with method, path, query, headers and body unchanged, through an ArmeriaWebClienttotarget, and streams the response back.Hostis rewritten to the target's address, as a reverse proxy would. A prefix that overlaps the UC or control API paths is rejected.UnityCatalogServer.Builder#forward(pathPrefix, target), which registers each forward on the API virtual host alongside the UC services.For #1825, the embedding code would be:
Compared with keeping the transcoder
Behavior and limits
forwardis called. No property or CLI flag is added; an embedding component such as [Server][OpenSharing 6/6] Serve the Delta Sharing protocol and recipient activation from Unity Catalog #1825 calls the builder.Tests
ArmeriaForwardTest: a separate Armeria server on loopback, reached only through UC's API port. Checks that a POST with a query, bearer token and JSON body arrives unchanged; that the component's status and headers come back; that UC routes and look-alike paths (/api/2.1/opensharingX) are not forwarded; and that an unreachable target returns a 5xx.UnityCatalogServerForwardTest: a fullUnityCatalogServerwith authorization enabled and a component on loopback. Through the one port, the component answers under its prefix while/api/2.1/unity-catalog/catalogsstill returns 401.ArmeriaServerBuilderTest: a forwarded prefix inside the UC API is rejected.Verification
build/sbt javafmtAllbuild/sbt "server/testOnly io.unitycatalog.server.UnityCatalogServerForwardTest io.unitycatalog.server.ArmeriaForwardTest io.unitycatalog.server.ArmeriaServerBuilderTest io.unitycatalog.server.UnityCatalogServerTest": 18 tests passed.🤖 Generated with Claude Code