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

Print messages about ports that can't change at runtime for K8s #33789

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

Sgitario
Copy link
Contributor

@Sgitario Sgitario commented Jun 2, 2023

Related to #33307, task 3.
Fix #32882

I didn't add this logic to Knative (because knative is renaming the port to http1) and Kind/Minikube because these are for DEV purposes only.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jun 2, 2023

@iocanel @cescoffier I'm not sure if this is what you had in mind for the task 3 of #33307.
Note that I don't think this message should use the INFO level, but DEBUG.

Comment on lines 221 to 223
LOG.info(String.format("The target '%s' is mapping the container to the port '%s' which value is '%d'. "
+ "You won't be able to change it at runtime using the property '%s'.",
target, port.getName(), port.getContainerPort(), portWithConfig.getValue().propertyName));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.info(String.format("The target '%s' is mapping the container to the port '%s' which value is '%d'. "
+ "You won't be able to change it at runtime using the property '%s'.",
target, port.getName(), port.getContainerPort(), portWithConfig.getValue().propertyName));
LOG.warn(String.format("'%s' manifests are generated with container port '%s' having value '%d'. "
+ "The above is influenced by property '%s' which may change at runtime. Such change is likely to cause problems as the application and the container configuration will get out of sync.",
target, port.getName(), port.getContainerPort(), portWithConfig.getValue().propertyName));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the message is now too long. Also, using a warning might cause some panic among users that as far as I know, never complained about this.

Copy link
Member

Choose a reason for hiding this comment

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

let's use info instead.

Copy link
Contributor

@iocanel iocanel left a comment

Choose a reason for hiding this comment

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

I found the message a bit misleading, so I suggested something different.

Also, since this pattern is something used in others places too, I am wondering if we should have a utility that does the config reading and logging. It would provide a more concise user experience and possibly make our lives easier years from now when we'll have forgotten all about it.

@quarkus-bot

This comment has been minimized.

Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

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

I like @iocanel suggestion.

@cescoffier
Copy link
Member

I agree about having a utility class with a consistent, wellformed, not misleading message.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jun 6, 2023

I'm -1 with the Ioannis' suggestion because the message is too long (imagine having the management port plus the HTTP port enabled), and I think that using the warning log level will cause some panic to users that as far as I know, never complained about this.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jun 6, 2023

After speaking with @iocanel , we agreed with changing the message to:
[INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] The 'kubernetes' manifests are generated with the container port 'http' having value '8080'. The app and manifests will get out of sync if the property 'quarkus.http.port' is changed at runtime..

PR updated

@quarkus-bot

This comment has been minimized.

@Sgitario Sgitario requested review from iocanel and cescoffier June 6, 2023 08:49
@quarkus-bot

This comment has been minimized.

Copy link
Contributor Author

@Sgitario Sgitario left a comment

Choose a reason for hiding this comment

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

I'm -1 to include these changes as it overcomplicates the logic for very little benefit (printing messages for users that as far as I know, they never complained about it).

Though, aside of my comments, I don't want to block this change as long as @iocanel and @cescoffier are ok with proceeding.

this.runtime = runtime;
}

public static <T> Property<T> fromBuildTimeConfiguration(String name, Class<T> type, T defaultValue) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since these changes are meant to print messages for runtime properties-related only.
What I was asking was to get rid of this method (and the runtime field) and use the PortConfig class directly in the printMessages method.

int port = ConfigProvider.getConfig().getOptionalValue("quarkus.grpc.server.port", Integer.class)
.orElse(9000);
return new KubernetesPortBuildItem(port, "grpc");
return KubernetesPortBuildItem.fromRuntimeConfiguration("https", "quarkus.grpc.server.port", 9000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the "enabled" flag here should be based on useSeparateServer boolean, not in the presence of the property.

return new KubernetesPortBuildItem(port, name, enabled, Optional.of(origin));
}

public static KubernetesPortBuildItem fromRuntimeConfiguration(String name, String propertyName, Integer defaultValue) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to my previous comment, I think this method can be deleted.

// If no kubernetes property is provided, this will be used instead.
String defaultOrProvided = extensionProperty.getValue().isPresent() ? "provided" : "default";
String stringValue = String.valueOf(extensionProperty.getValue().orElse(extensionProperty.getDefaultValue()));
LOG.infof("Kubernetes manifests are generated with '%s' having %s value '%s'. "
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This message can be confused when using the OpenShift, Knative, etc. Kubernetes should be replaced with the target generator.

// We have conflicting properties that need to be aligned. Maybe warn?
String runtimeOrBuildTime = extensionProperty.isRuntime() ? "runtime" : "buildtime";
LOG.debugf(
"Kubernetes property '%s' has been set with value '%s' while %s property '%s' is set with '%s'. %s will be set using the former.",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here, Kubernetes should be replaced with the target generator.

@@ -291,8 +291,7 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
result.add(new DecoratorBuildItem(KUBERNETES, new RemovePortFromServiceDecorator(name, MANAGEMENT_PORT_NAME)));
}

printMessageAboutPortsThatCantChange(KUBERNETES, ports, config);

printMessageAboutPortsThatCantChange(name, ports, config);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, name should be KUBERNETES

@@ -380,8 +380,7 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
result.add(new DecoratorBuildItem(OPENSHIFT, new RemovePortFromServiceDecorator(name, MANAGEMENT_PORT_NAME)));
}

printMessageAboutPortsThatCantChange(OPENSHIFT, ports, config);

printMessageAboutPortsThatCantChange(name, ports, config);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, name should be OPENSHIFT

* For example the presence `quarkus.http.ssl-port` also is not enought to tell us if enabled.
* Still, we need to communicate its value and let `quarkus-kubernetes` extension decide.
**/
private final boolean enabled;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still confuses me to generate build items that are not enabled.
I know you explained to me that this is necessary for the case when users add quarkus.kubernetes.ports.https.tls=true, so the container port for https is resolved from here.

@Sgitario Sgitario requested a review from cescoffier June 19, 2023 11:57
@Sgitario
Copy link
Contributor Author

@cescoffier can you take another look to this pull request after the changes made by Ioannis please?

@iocanel iocanel force-pushed the 32882 branch 2 times, most recently from fc94e67 to fe95708 Compare June 19, 2023 12:57
@quarkus-bot

This comment has been minimized.

@cescoffier
Copy link
Member

The CI issues might be related.

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 25, 2023

Failing Jobs - Building de116aa

Status Name Step Failures Logs Raw logs
JVM Tests - JDK 11 Build Failures Logs Raw logs
JVM Tests - JDK 17 Build Failures Logs Raw logs
✔️ JVM Tests - JDK 19
✔️ Maven Tests - JDK 11
Maven Tests - JDK 11 Windows Build Failures Logs Raw logs
Native Tests - Security1 Build ⚠️ Check → Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ JVM Tests - JDK 11 #

- Failing: integration-tests/grpc-hibernate 

📦 integration-tests/grpc-hibernate

com.example.grpc.hibernate.VertxBlockingMutinyTest.shouldAddItems - More details - Source on GitHub

io.smallrye.mutiny.CompositeException: 
Multiple exceptions caught:
	[Exception 0] io.grpc.StatusRuntimeException: INTERNAL: Half-closed without a request

⚙️ JVM Tests - JDK 17 #

- Failing: integration-tests/grpc-hibernate 

📦 integration-tests/grpc-hibernate

com.example.grpc.hibernate.VertxBlockingMutinyTest.shouldAddItems - More details - Source on GitHub

io.smallrye.mutiny.CompositeException: 
Multiple exceptions caught:
	[Exception 0] io.grpc.StatusRuntimeException: INTERNAL: Half-closed without a request

⚙️ Maven Tests - JDK 11 Windows #

📦 integration-tests/maven

io.quarkus.maven.it.DevMojoIT.testResourcesFromClasspath line 1234 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.maven.it.DevMojoIT was not fulfilled within 20 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

io.quarkus.maven.it.DevMojoIT.testResourcesFromClasspath line 1234 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with io.quarkus.maven.it.DevMojoIT was not fulfilled within 20 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

Copy link
Contributor

@iocanel iocanel left a comment

Choose a reason for hiding this comment

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

LGTM

@iocanel
Copy link
Contributor

iocanel commented Jul 26, 2023

Don't think the failures are related.

@iocanel
Copy link
Contributor

iocanel commented Jul 26, 2023

Don't think the failures are related.

Verified that the same tests fail in other pull requests too. So, I'll merge.

@iocanel iocanel merged commit c00bbdb into quarkusio:main Jul 26, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 26, 2023
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.

Changing port numbers at runtime leads to deployment errors when using K8s/OpenShift extensions
3 participants