Skip to content
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

In WSL dev/test mode print localhost instead of 0.0.0.0 in serverListeningMessage #40700

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

tamaro-skaljic
Copy link
Contributor

Like #40497 but with requested changes #40497 (review).

@tamaro-skaljic
Copy link
Contributor Author

@gsmet From a new branch because the last PR was from my main branch...

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Indeed, always push your PR from a feature branch.

This looks mostly good to me except for one concern, serious in one case and more for consistency in the other.

Could you have a look?

@@ -24,7 +24,7 @@ public boolean isDevOrTest() {
* Returns true if the current launch is the server side of remote dev.
*/
public static boolean isRemoteDev() {
return (current() == DEVELOPMENT) && "true".equals(System.getenv("QUARKUS_LAUNCH_DEVMODE"));
return (current() == DEVELOPMENT) && System.getenv("QUARKUS_LAUNCH_DEVMODE").equals("true");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't change this. It looks odd but this is actually the safer pattern as it works even if System.getenv("QUARKUS_LAUNCH_DEVMODE") is null. Your new pattern will fail with a NPE in this case.

You know it once you got bitten by it :).

* Do not use this during the actual configuration, use options.getHost() there directly instead.
*/
private static String getDeveloperFriendlyHostName(HttpServerOptions options) {
return (isWSL() && LaunchMode.current().isDevOrTest() && options.getHost().equals("0.0.0.0")) ? "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think getHost() can ever return null but I would use the safe pattern here too and have 0.0.0.0 first.

@gsmet
Copy link
Member

gsmet commented May 28, 2024

Hey @tamaro-skaljic , do you wish to finalize this PR or do you want me to finalize it?

tamaro-skaljic and others added 2 commits June 6, 2024 17:15
The previous commit was actually changing the logic for the default
case.
@gsmet gsmet force-pushed the improve-dev-experience-on-wsl branch from 1d5003c to 64bf132 Compare June 6, 2024 15:28
Comment on lines 16 to 36
if (builder.getDefaultValues().get(QUARKUS_HTTP_HOST) == null) {
// Sets the default host config value, depending on the launch mode
if (LaunchMode.isRemoteDev()) {
// in remote-dev mode we need to listen on all interfaces
// in remote dev mode, we want to listen on all interfaces
// to make sure the application is accessible
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
} else if (LaunchMode.current().isDevOrTest()) {
if (!isWSL()) {
// in dev mode, we want to listen only on localhost
// to make sure the app is not accessible from the outside
builder.withDefaultValue(QUARKUS_HTTP_HOST, LOCALHOST);
} else {
// except when using WSL, as otherwise the app wouldn't be accessible from the host
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
}
} else {
// In dev-mode we want to only listen on localhost so others on the network cannot connect to the application.
// However, in WSL this would result in the application not being accessible,
// so in that case, we launch it on all interfaces.
builder.withDefaultValue(QUARKUS_HTTP_HOST,
(LaunchMode.current().isDevOrTest() && !isWSL()) ? "localhost" : ALL_INTERFACES);
// in all the other cases, we make sure the app is accessible on all the interfaces by default
builder.withDefaultValue(QUARKUS_HTTP_HOST, ALL_INTERFACES);
}
}
return builder;
Copy link
Member

@gsmet gsmet Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmlloyd could you have a look at this change as it could have some security consequences?

I adjusted it because the previous commit by the OP actually changed the default value and I wanted to make it extra clear (even if a bit more verbose).

The new version should be exactly as what we have in main.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gsmet gsmet added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 6, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 6, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 64bf132.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 17

📦 integration-tests/reactive-messaging-kafka

io.quarkus.it.kafka.KafkaConnectorTest.testFruits - History

  • Assertion condition defined as a Lambda expression in io.quarkus.it.kafka.KafkaConnectorTest expected: <6> but was: <5> within 10 seconds. - org.awaitility.core.ConditionTimeoutException
org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a Lambda expression in io.quarkus.it.kafka.KafkaConnectorTest expected: <6> but was: <5> within 10 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006)
	at org.awaitility.core.ConditionFactory.untilAsserted(ConditionFactory.java:790)
	at io.quarkus.it.kafka.KafkaConnectorTest.testFruits(KafkaConnectorTest.java:63)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  • Assertion condition defined as a Lambda expression in io.quarkus.it.kafka.KafkaConnectorTest expected: <6> but was: <5> within 10 seconds. - org.awaitility.core.ConditionTimeoutException
org.awaitility.core.ConditionTimeoutException: Assertion condition defined as a Lambda expression in io.quarkus.it.kafka.KafkaConnectorTest expected: <6> but was: <5> within 10 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006)
	at org.awaitility.core.ConditionFactory.untilAsserted(ConditionFactory.java:790)
	at io.quarkus.it.kafka.KafkaConnectorTest.testFruits(KafkaConnectorTest.java:63)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

⚙️ JVM Tests - JDK 21

📦 extensions/micrometer/deployment

io.quarkus.micrometer.deployment.binder.VertxConnectionMetricsTest.testConnectionMetrics - History

  • event executor terminated - java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException: event executor terminated
	at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:934)
	at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:351)
	at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:344)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:836)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute0(SingleThreadEventExecutor.java:827)
	at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:817)
	at io.vertx.core.impl.EventLoopExecutor.execute(EventLoopExecutor.java:35)

📦 extensions/smallrye-reactive-messaging-kafka/deployment

io.quarkus.smallrye.reactivemessaging.kafka.deployment.dev.KafkaDevServicesDevModeTestCase.sseStream - History

  • Assertion condition defined as a Lambda expression in io.quarkus.smallrye.reactivemessaging.kafka.deployment.dev.KafkaDevServicesDevModeTestCase Expecting size of: [] to be greater than or equal to 2 but was 0 within 10 seconds. - org.awaitility.core.ConditionTimeoutException
org.awaitility.core.ConditionTimeoutException: 
Assertion condition defined as a Lambda expression in io.quarkus.smallrye.reactivemessaging.kafka.deployment.dev.KafkaDevServicesDevModeTestCase 
Expecting size of:
  []
to be greater than or equal to 2 but was 0 within 10 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:119)
	at org.awaitility.core.AssertionCondition.await(AssertionCondition.java:31)

@gsmet gsmet merged commit 66263bd into quarkusio:main Jun 7, 2024
52 checks passed
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 7, 2024
@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone Jun 7, 2024
@gsmet
Copy link
Member

gsmet commented Jun 7, 2024

@tamaro-skaljic thanks for raising this and working on a patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants