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

Do not discover properties resource in the classpath to avoid missing resources registration in native mode #44910

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radcortez
Copy link
Member

@radcortez radcortez commented Dec 3, 2024

Disable automatic discovery of configuration resources in native mode.

While it has always been enabled, it didn't have any effect because we never registered the resources in the native image. The configuration still worked, because we recorded the configuration during build time.

I did try to disable it as well for JVM mode, but it is a bit more tricky:

  • Our testing API can add additional classpath resources after we build Quarkus, which wouldn't be caught with this.
  • Debugging would be harder, because it would lose the the origin source from where the configuration is coming from.
  • Flattening has a corner case issue described in Register default configuration smallrye configuration files as resources #44652 (comment). This was never really an issue, but there is a test in the TCK that fails because of this.

Ideally, both JVM and native mode should be the same, but at the moment they're not. While this doesn't solve that particular issue, it should at least fix the missing registration warnings / errors without changing the current behaviour.

Alternate proposal to #42140.

This comment has been minimized.

@geoand
Copy link
Contributor

geoand commented Dec 4, 2024

CI failures seem related

@radcortez
Copy link
Member Author

CI failures seem related

Yes

@radcortez
Copy link
Member Author

I was expecting more actually :)

@radcortez radcortez force-pushed the disable-config-properties-scan branch from 74e2236 to 8cbb860 Compare December 4, 2024 13:33
@radcortez radcortez changed the title Do not discover properties resource in the classpath since they are already recorded during build time Do not discover properties resource in the classpath to avoid missing resources registration in native mode Dec 4, 2024

This comment has been minimized.

Copy link

github-actions bot commented Dec 4, 2024

🎊 PR Preview 43f9421 has been successfully built and deployed to https://quarkus-pr-main-44910-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

This comment has been minimized.

@radcortez radcortez force-pushed the disable-config-properties-scan branch from 8cbb860 to 784a1fe Compare December 11, 2024 18:47

This comment has been minimized.

This comment has been minimized.

@zakkak
Copy link
Contributor

zakkak commented Jan 10, 2025

@radcortez what's the status of this PR, is it ready for review and merging?

@radcortez
Copy link
Member Author

Yes, if you are happy with it :)

Copy link
Contributor

@zakkak zakkak left a comment

Choose a reason for hiding this comment

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

LGTM, but I have a concern about this being a breaking change, see comments.

Comment on lines +14 to +16
* configuration will still be available. If the users change the ordinals of the sources in runtime, it may
* cause unexpected values to be returned by the config, but this has always been the case. The classpath configuration
* resources were never registered in the native image.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this true?

In oracle/graal#10264 (reply in thread) we describe a scenario were using the classpath would work fine (assuming the user registers the resource for reflection and sets the ordinals accordingly).

Copy link
Member Author

Choose a reason for hiding this comment

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

With our stuff yes, we never registered the resources. The configuration is just included in a class file and we discard the resources, which may cause the issue described in #44652 (comment), but this has been an issue since day one and until now we never got any complaints about it.

static final class Target_AbstractLocationConfigSourceLoader {
@Substitute
protected List<ConfigSource> tryClassPath(final URI uri, final int ordinal, final ClassLoader classLoader) {
return Collections.emptyList();
Copy link
Contributor

Choose a reason for hiding this comment

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

If what my previous comment is right, this is a breaking (for quite a corner case I admit) change, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this could be a breaking change if a user has a custom source with a custom resource. If they are registering the resource manually they would need to process the file and generate some sort of representation (like us) for runtime.

Unfortunately, I don't see any good alternative. Having to forcely register all the resources is going to throw away all of our optimizations. If we leave it as is, you get the error that we are trying to prevent. (Well I guess we could add a try / catch there instead).

I still think it doesn't make sense to apply that validation to an API like ClassLoader#getResources. That API never fails in JVM mode, no matter what you are looking for. Granted that you can obtain different results from JVM to native if the registrations are not done properly, but the native image shouldn't try to outsmart the library or integrator by changing API behaviours.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, I don't see any good alternative.

I am personally fine with this, since it's a corner case. I am not even sure we need to document this kind of "breakage".

Copy link
Contributor

Choose a reason for hiding this comment

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

@radcortez I went on with adding a try/catch. Please have a look.

@zakkak zakkak force-pushed the disable-config-properties-scan branch from 784a1fe to 8733462 Compare January 14, 2025 09:58
Copy link

quarkus-bot bot commented Jan 14, 2025

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 8733462.

✅ 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.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

Copy link

quarkus-bot bot commented Jan 14, 2025

Status for workflow Quarkus CI

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

✅ 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 Windows

📦 integration-tests/grpc-hibernate

com.example.grpc.hibernate.BlockingRawTest.shouldAdd - History

  • Condition with Lambda expression in com.example.grpc.hibernate.BlockingRawTestBase was not fulfilled within 30 seconds. - org.awaitility.core.ConditionTimeoutException
org.awaitility.core.ConditionTimeoutException: Condition with Lambda expression in com.example.grpc.hibernate.BlockingRawTestBase was not fulfilled within 30 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:167)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:26)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:1006)
	at org.awaitility.core.ConditionFactory.until(ConditionFactory.java:975)
	at com.example.grpc.hibernate.BlockingRawTestBase.shouldAdd(BlockingRawTestBase.java:59)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)

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.

Enhance SmallRyeConfig handling
3 participants