Repository navigation
[Server] Serve clients from Armeria directly and remove the Vert.x URL transcoder - #1979
Conversation
f6e01b1 to
eeddeb6
Compare
…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]>
eeddeb6 to
3715b33
Compare
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]>
|
Hi @s-maling-celonis. While this Vert.x URL transcoder is largely useless for now, we are finding new use of it: running other pluggable component so that it helps to consolidate all endpoints in one single public facing listening port. So I think we'll still keep it. |
|
@yili-db Thank you for linking to the OpenSharing use case. I still believe this, and all the required features, are fully achievable with just Armeria. For example, I created a draft PR, #2036, which shows how Armeria can forward from the public port to OpenSharing. In the meantime, I've also opened #2035 to bump Vert.x. A Vert.x security vulnerability and the Netty version misalignment between Vert.x and Armeria are what originally led me to investigate why both Vert.x and Armeria are used. |
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] nit: docs/integrations/unity-catalog-puppygraph.md:207 says "8081 is used by Unity Catalog", which is no longer true now that nothing binds port + 1.
| // threads holding it open with nothing listening. | ||
| try { | ||
| vertx.deployVerticle(transcodeVerticle).toCompletionStage().toCompletableFuture().join(); | ||
| unityCatalogServer.start(); |
There was a problem hiding this comment.
[AI Assisted] The deleted testDeploymentFailsWhenTheTranscodePortIsTaken was the only test that a taken port fails startup. Can we add one? Start a server on a port held by a ServerSocket, expect a CompletionException caused by ServerPortBindException, and check close() still succeeds.
There was a problem hiding this comment.
Added startFailsWhenThePortIsTaken in UnityCatalogServerTest in 53c11d9. It holds a port with a ServerSocket, expects start() to throw a CompletionException caused by ServerPortBindException, then checks that close() doesn't throw. This also covers the cause that BaseServerTest's retry depends on.
| try { | ||
| vertx.deployVerticle(transcodeVerticle).toCompletionStage().toCompletableFuture().join(); | ||
| unityCatalogServer.start(); | ||
| } catch (CompletionException e) { |
There was a problem hiding this comment.
[AI Assisted] Only CompletionException is caught here. start() runs cleanupWorker.start() after Armeria is already listening, so a RuntimeException from it skips close() and can leave the process running with the port held. Should this catch RuntimeException?
There was a problem hiding this comment.
Good catch. main() now catches RuntimeException, so a failure in cleanupWorker.start() after Armeria is listening also goes through close(). It logs the whole exception now, since an exception thrown directly has no useful cause. Fixed in 53c11d9.
| // Iceberg clients join nested namespace levels with %1F. It is not rewritten to a period, so | ||
| // the name matches no schema and the namespace is reported missing. | ||
| assertErrorType( | ||
| client.get(TEST_BASE_PREFIX + "/namespaces/nested%1Fnamespace").aggregate().join(), |
There was a problem hiding this comment.
[AI Assisted] The description also lists ?parent=a%1Fb returning 404, but only the path form is tested here. Can you add the query form too?
Also, the comment on the nested.namespace case above now reads as if that is how a nested namespace arrives. It arrives with U+001F instead, so can you reword it to say that . names are rejected as invalid, while U+001F names are simply not found?
There was a problem hiding this comment.
Added ?parent=nested%1Fnamespace → 404 NoSuchNamespaceException to the ListNamespaces test, next to the existing ?parent=noSuchSchema case. I also reworded the nested.namespace comment to say that names containing a period are rejected as invalid. The %1F comment below it already says those names are simply not found.
| unityCatalogServer.start(); | ||
| } catch (CompletionException e) { | ||
| unityCatalogServer.close(); | ||
| unityCatalogServer = null; |
There was a problem hiding this comment.
[AI Assisted] nit: on the last failed attempt, unityCatalogServer is set to null before the rethrow, so tearDown skips hibernateConfigurator.close() and the pool leaks. It only happens when setup already failed, so low priority.
There was a problem hiding this comment.
Fixed. When the last start attempt fails, the injected hibernateConfigurator is now closed before the rethrow, since tearDown skips a null server.
@s-maling-celonis I think this PR is good. Removing Vert.x is the right move. Thanks! |
- main closes the server on any RuntimeException from start(), not only a CompletionException. cleanupWorker.start() runs after Armeria is listening, so a failure there used to leave the port held. - Test that a taken port fails start() with a ServerPortBindException cause and that close() still succeeds. The removed transcoder test was the only coverage of this, and BaseServerTest's retry relies on that cause. - Test that ?parent=a%1Fb is a missing namespace (404), alongside the path form, and reword the period-name comment to say such names are rejected as invalid. - BaseServerTest closes the injected Hibernate configurator when the last start attempt fails, since tearDown skips a null server. - The PuppyGraph guide points at Unity Catalog on 8080 instead of 8081, which nothing binds any more, and no longer says 8081 is taken. Signed-off-by: s-maling-celonis <[email protected]>
|
Thanks, fixed the line 207 note. The same guide had a second stale port: |
…nto upstream-pr/remove-vertx-transcoder Signed-off-by: s-maling-celonis <[email protected]> # Conflicts: # build.sbt # server/src/test/java/io/unitycatalog/server/UnityCatalogServerTest.java # server/src/test/java/io/unitycatalog/server/base/BaseServerTest.java
|
/review |
PR Checklist
docsis updatedDescription of changes
Today the launcher runs a Vert.x verticle on the client port. It forwards every request over HTTP/1.1 to Armeria on
port + 1. It does one rewrite: Iceberg's nested-namespace separator%1Fbecomes., in the path and in query values. Unity Catalog has no nested namespaces, so that rewrite doesn't make any request succeed. It only changes which error a client gets for a name it could never resolve.#1918 had to size the transcoder's connection pool to the JDBC pool, and answer
/livezin front of it, so a saturated proxy wouldn't become the bottleneck. Removing the transcoder makes all of that unnecessary.This change:
URLTranscoderVerticleand thevertx-core,vertx-webandvertx-web-clientdependencies;-pport inmain, instead ofport + 1, and closes the server if it can't start;port + 1handling from the observability-port check;docs/server/observability.md, which described the client port and the internalport + 1API port.Reasons
\^_transcoding: Unity Catalog has no nested namespaces, so rewriting%1Fto.never made a request succeed.vertx-core,vertx-webandvertx-web-clientare removed, so there are fewer libraries to patch for CVEs./livezin front of it.127.0.0.1, which helps logging and metrics.Behavior changes
port + 1any more.GET /v1/catalogs/{c}/namespaces/a%1FbandGET /v1/catalogs/{c}/namespaces?parent=a%1Fbnow return404 NoSuchNamespaceExceptioninstead of400. Neither form ever matched a schema.hostname_patternlabel ofhttp_server_requests_totalnow names the-pport (*:8080by default) instead ofport + 1(*:8081). Dashboards or alerts that filter on*:8081need updating.No REST API, property, or CLI changes.
Verification
build/sbt javafmtAllbuild/sbt "server/testOnly io.unitycatalog.server.ArmeriaServerBuilderTest io.unitycatalog.server.UnityCatalogServerTest io.unitycatalog.server.UnityCatalogServerShutdownTest io.unitycatalog.server.EventLoopStallTest io.unitycatalog.server.service.IcebergRestCatalogTest": 42 tests. The first run had oneServerPortBindExceptionon a random test port.IcebergRestCatalogTestthen passed 26/26 on rerun.🤖 Generated with Claude Code