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

Refactor configuration completely #692

Merged
merged 1 commit into from
Feb 1, 2019
Merged

Refactor configuration completely #692

merged 1 commit into from
Feb 1, 2019

Conversation

dmlloyd
Copy link
Member

@dmlloyd dmlloyd commented Jan 31, 2019

• support multiple levels of hierarchy
• handle at augment time via reflection instead of using code generation
• distinguish build-/run-time injection items
• generate config parsing with unknown key detection
• lighten annotation processing to work better with eclipse (hopefully)
• support a wide range of configuration types
• require explicit specification of build phase for configuration groups

Co-authored-by: Alexey Loubyansky loubyansky@gmail.com
Co-authored-by: Stuart Douglas stuart.w.douglas@gmail.com

@FroMage
Copy link
Member

FroMage commented Jan 31, 2019

And they say my PRs are too big ;)

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

Well this was working. Infinispan has just come in and broken it. Repair incoming.

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

Though I've requested a few reviews, and others are welcome to review as well, I'd prefer to merge this and fix anything else after, unless there's something catastrophic.

@FroMage
Copy link
Member

FroMage commented Jan 31, 2019

+1

@Sanne
Copy link
Member

Sanne commented Jan 31, 2019

I've had a failure in module shamrock-integration-test-vertx when enabling -Dnative during local testing:

[INFO] Running org.jboss.shamrock.vertx.runtime.tests.VertxProducerResourceIT
Executing /home/sanne/sources/shamrock/integration-tests/vertx/target/shamrock-integration-test-vertx-1.0.0.Alpha1-SNAPSHOT-runner
java.lang.ExceptionInInitializerError
	at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:281)
	at java.lang.Class.ensureInitialized(DynamicHub.java:375)
	at org.jboss.shamrock.deployment.steps.LoggingResourceProcessor$setupLoggingRuntimeInit1.deploy(Unknown Source)
	at org.jboss.shamrock.runner.ApplicationImpl1.doStart(Unknown Source)
	at org.jboss.shamrock.runtime.Application.start(Application.java:90)
	at org.jboss.shamrock.runtime.Application.run(Application.java:190)
	at org.jboss.shamrock.runner.GeneratedMain.main(Unknown Source)
Caused by: java.lang.IllegalArgumentException: No Converter registered for class class java.time.Duration
	at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:152)
	at io.smallrye.config.SmallRyeConfig.convert(SmallRyeConfig.java:132)
	at org.jboss.shamrock.runtime.generated.ConfigHelper.init:vertx(Unknown Source)
	at org.jboss.shamrock.runtime.generated.ConfigHelper.<clinit>(Unknown Source)
	at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:341)
	at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:261)
	... 6 more
Exception in thread "main" java.lang.RuntimeException: Failed to start shamrock
	at org.jboss.shamrock.runner.ApplicationImpl1.doStart(Unknown Source)
	at org.jboss.shamrock.runtime.Application.start(Application.java:90)
	at org.jboss.shamrock.runtime.Application.run(Application.java:190)
	at org.jboss.shamrock.runner.GeneratedMain.main(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
	at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:281)
	at java.lang.Class.ensureInitialized(DynamicHub.java:375)
	at org.jboss.shamrock.deployment.steps.LoggingResourceProcessor$setupLoggingRuntimeInit1.deploy(Unknown Source)
	... 4 more
Caused by: java.lang.IllegalArgumentException: No Converter registered for class class java.time.Duration
	at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:152)
	at io.smallrye.config.SmallRyeConfig.convert(SmallRyeConfig.java:132)
	at org.jboss.shamrock.runtime.generated.ConfigHelper.init:vertx(Unknown Source)
	at org.jboss.shamrock.runtime.generated.ConfigHelper.<clinit>(Unknown Source)
	at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:341)
	at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:261)
	... 6 more

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

Easy fix, I suppose.

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

It's not clear why this one isn't using an implicit converter. They cannot be disabled AFAICT.

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

Ah of course, native image. I'll have to probe these at startup.

@Sanne
Copy link
Member

Sanne commented Jan 31, 2019

considering config might change.. should we just register all known converters for reflective access?

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

Yeah. It's going to be a little bit of a challenge though; I'll have to make a build item for it.

@ConfigProperty(name = "url")
public String url;
@ConfigItem
public Optional<String> url;
Copy link
Member

Choose a reason for hiding this comment

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

the connection url is mandatory to define a datasource. Do we still need these to be Optional now?

Copy link
Member Author

Choose a reason for hiding this comment

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

For now this is the only way I could exactly replicate the previous logic, which relied on optional configuration groups which will no longer be supported.

Once this is in, I think it's OK to change this to whatever is the best fit for the extension.

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing to note is that you are not allowed to have mandatory properties in any event. So, typically this means you have to intelligently disable your service when required configuration is not present. Making a property non-optional means you'll have to have a null/empty check.

Copy link
Member

Choose a reason for hiding this comment

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

not allowed to have mandatory properties in any event

"event" ?

So we just validate within the logic of the extensions, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

"in any event" == "in any case/situation", sorry for the ambiguous language.

Yeah the extensions have to do validation though adding generalized validation for extension config is also on my todo list.

But the reason that mandatory properties cannot work is that our model allows extensions to be brought in by other extensions, and yet we have a mandate to start up with little or zero configuration in a useful state. Allowing mandatory configuration items will break this badly. So validation should be constrained to just verifying that values that were specified are in bounds, or should otherwise only fail as a result of something the user has done wrong (as opposed to something that happened automatically).

So a good semantic is to define the minimum property or properties that are required to enable the extension, and if none are given, that means "do not add this service", and if they're only partial, perhaps log a warning that some required properties are not present so the service is not activated. Only produce an error (stop) when there is a value explicitly specified, but it is not valid.

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 31, 2019

A fix for the converter issue is coming tomorrow. We don't want to merge this yet if it's going to break CI.

  • support multiple levels of hierarchy
  • handle at augment time via reflection instead of using code generation
  • distinguish build-/run-time injection items
  • generate config parsing with unknown key detection
  • lighten annotation processing to work better with eclipse (hopefully)
  • support a wide range of configuration types
  • require explicit specification of build phase for configuration groups

Co-authored-by: Alexey Loubyansky <loubyansky@gmail.com>
Co-authored-by: Stuart Douglas <stuart.w.douglas@gmail.com>
@dmlloyd
Copy link
Member Author

dmlloyd commented Feb 1, 2019

OK everything should be solved... pending CI.

@dmlloyd dmlloyd merged commit 0a09e82 into quarkusio:master Feb 1, 2019
@dmlloyd dmlloyd deleted the config-new branch February 1, 2019 09:26
@gsmet gsmet added this to the 0.8.0 milestone Feb 1, 2019
@objectiser
Copy link
Contributor

@dmlloyd Will there be further doc updates, as they are still referring to @ConfigProperty, instead of @configitem?

Also - do the properties still come from MP-config? i.e. microprofile-config.properties

@dmlloyd
Copy link
Member Author

dmlloyd commented Feb 1, 2019

Sure I"ll add a todo for the docs; I will probably largely cut & paste them from the summary emails I'm going to be writing on the plane tomorrow.

Yeah still using microprofile-config.properties for the moment.

@cescoffier
Copy link
Member

@dmlloyd should we use this opportunity to change the name and location of the file?

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

Successfully merging this pull request may close these issues.

7 participants