-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable usage of random port for the Management Interface #39588
Conversation
This comment has been minimized.
This comment has been minimized.
🙈 The PR is closed and the preview is expired. |
|
||
@Test | ||
public void test() { | ||
Assertions.assertNotEquals(url.getPort(), management.getPort()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 ;)
@@ -644,9 +665,21 @@ private static CompletableFuture<HttpServer> initializeManagementInterface(Vertx | |||
} | |||
|
|||
actualManagementPort = ar.result().actualPort(); | |||
if (actualManagementPort != httpManagementServerOptions.getPort()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder, is this enough from preventing vertx to round-robin?
(Only see this managing system properties - so I'm a bit confused)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes how it is retrieved and invoked (the system property is used to inject the URL in the test). I was not able to get the same port for both the primary and management ports. I repeated the tests many times without luck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.
[stdout] 2024-03-21 10:43:54,019 INFO [io.quarkus] (main) nessie-quarkus 0.79.1-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 1.830s. Listening on: http://0.0.0.0:44735. Management interface listening on http://0.0.0.0:44735.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repro:
- Clone from this repo:
git clone -o snazy -b quarkus-management-http-JAVA_HTTP_QUARKUS_DEBUG https://github.com/snazy/nessie.git
(hope I got the git syntax right) - Build Quarkus (
./mvnw -Dquickly -T1C
) - Build and start:
./gradlew :nessie-quarkus:quarkusBuild && java -Dquarkus.http.port=0 -Dquarkus.management.port=0 -jar servers/quarkus-server/build/quarkus-app/quarkus-run.jar
(EDIT: Removed the intTest
example - requires changes to the source code for the random port)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - the round-robin behavior is reproducible w/ curl
:
curl http://127.0.0.1:39135/api/v1/config
Good:
$ curl http://127.0.0.1:39135/api/v1/config
{
"defaultBranch" : "main",
"maxSupportedApiVersion" : 2
}
Bad:
$ curl http://127.0.0.1:39135/api/v1/config
<html><body><h1>Resource not found</h1></body></html>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It's weird that you end up with the same port. I believe it's a timing issue (like your machine is super fast and so the 2 random are generated exactly at the same time).
This comment has been minimized.
This comment has been minimized.
Looks like the "magic values" -1 & -2 are the issue here.
:) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
270e060
to
4cc7eea
Compare
@snazy alright! I've integrated your commit and did a few cosmetic fixes. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/** | ||
* When the management port is set to 0, replace it by this value to let Vert.x choose a random port | ||
*/ | ||
public static final int RANDOM_PORT_MANAGEMENT = -3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need one for managment/TLS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, management has only one port. Unlike the primary HTTP server which can serve both HTTP and HTTPS at the same time (using 2 ports), it's not possible with the management interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
super weird compilation issue - as it compiles locally (using java 17 and 21, doing clean too) |
I have not encountered it... |
ok, it's actually some kind of conflict... I don't like when the main HTTP recorder gets modified without me reviewing it. |
Which PR made a change? |
In testing scenarios, setting the management interface port to a random value can be beneficial. This can be achieved by configuring `quarkus.management.test-port` to `0`. However, previously, retrieving the actual port in tests was not feasible. This commit addresses this limitation by introducing the following enhancements: - It stores the actual management port in a system property when it differs from the configured port. - It enables the injection of the actual management port using @TestHTTPResource(management=true,...).
4cc7eea
to
d0d5ef5
Compare
Status for workflow
|
Status for workflow
|
Setting the management interface port to a random value in testing scenarios can be beneficial. This can be achieved by configuring
quarkus.management.test-port
to0
. However, retrieving the actual port in tests was not feasible previously.This PR addresses this limitation by introducing the following enhancements:
@TestHTTPResource(management=true,...)
.