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

7000 mpconfig version #8824

Merged
merged 7 commits into from
Dec 16, 2022
Merged

Conversation

poikilotherm
Copy link
Contributor

@poikilotherm poikilotherm commented Jun 30, 2022

What this PR does / why we need it:
By simplifying the way to set the version and build number, the container setup is already simplified. There is no need to include some special Maven files anymore, as Maven takes care of providing the version number via the META-INF/properties file.

Relates to #7000

Which issue(s) this PR closes:
None.

Special notes for your reviewer:
It is a good and simple start to see how the pieces laid out in #8823 are coming together in a simple first usage.

Suggestions on how to test this:
Play around with the settings described in the little dev docs section and watch it work. Or take a look at the nice test example, also using the new shiny @JvmSetting test extension!

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Not really.

Is there a release notes update needed for this change?:
Maybe? Dunno. Please leave comment. IMHO this is very much dev-only.

Additional documentation:
Included.

@poikilotherm poikilotherm added Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: Developer Guide Component: Containers Anything related to cloudy Dataverse, shipped in containers. labels Jun 30, 2022
// which contains in the source a Maven property reference to ${project.version}.
// When packaging the app to deploy it, Maven will replace this, rendering it a static entry.
// NOTE: MicroProfile Config will cache the entry for us in internal maps.
String appVersion = JvmSettings.VERSION.lookup();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the version info is accessed very frequently (every page view), it's debatable if we should cache the app version ourselves as done before and not rely on MPCONFIG for that (the spec does not guarantee caching).

@coveralls
Copy link

coveralls commented Jul 19, 2022

Coverage Status

Coverage decreased (-0.008%) to 19.989% when pulling 4ed1013 on poikilotherm:7000-mpconfig-version into be48cfd on IQSS:develop.

Instead of trying to read a built time file from Maven,
use MicroProfile Config to retrieve the version and build number.

The version is by default set via microprofile-config.properties
(or overridden by an env var in a container).

The build number is still read from either BuildNumber.properties
or, if not present, from MicroProfile Config, defaulting to empty.

This also avoids copying extra files into containers to retrieve
the version string.
@mreekie mreekie added the bk2211 label Nov 1, 2022
Copy link
Member

@qqmyers qqmyers left a comment

Choose a reason for hiding this comment

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

Looks fine to me. I raised a couple minor questions for @poikilotherm where he might want to make changes. I'm approving since I don't think either thing would require re-review if he does make changes.

assertTrue(result.startsWith("100.100"), "'" + result + "' not starting with 100.100");
assertTrue(result.contains("build"));

// Cannot test this here - there might be the bundle file present which is not under test control
Copy link
Member

Choose a reason for hiding this comment

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

A bundle entry would affect the real app the same way, right? So should this test be here to assure the default app is not shipping a bundle file that's going to override this setting? Or should the code prioritize the mpconfig value over any hardcoded bundle entry (that would allow the test to work, but is it also a better choice for the app - should you have to delete a bundle entry to be able to control build number? I'm asking and not recommending - you/others probably have a better sense of whether a bundle entry should have precedence or just be a default.)

Copy link
Contributor Author

@poikilotherm poikilotherm Dec 6, 2022

Choose a reason for hiding this comment

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

I gave this a bit of though today.

I don't really have an opinion on what should be preferred, because I do have the flexibility to have it configured with this PR merged.

Excluding the file via an <exclude> in the resources means it would not be picked up for testing deployments, too. But a unit test is kind of strange place to verify a file is not present under certain conditions.

We could also switch from using a bundle to the same trick used for the version - make it a Maven property, defaulting to empty, getting filtered in microprofile-config.properties at build time. Make it usable in any CI context or custom builds, not using hacks. Could also refer other vars, e.g. by the git-commit Maven plugin if people wish to do so.

Let me know what y'all think, given the fact that the Bundle file was an occasional problem before.

Copy link
Member

Choose a reason for hiding this comment

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

@poikilotherm my first thought is that this shouldn't be at the top of the community backlog if there's still stuff to figure out! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😲

Why is that? It's the first time this code is getting a review and raised a question from a core member. I was fine with the code as is, it works as designed and tested. Maybe I'm getting the scope of "review" wrong?

Copy link
Member

Choose a reason for hiding this comment

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

@poikilotherm ok, it helps to know that you're still fine with the PR, as-is. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

When I run this test I get this as the result:

100.100 build pdurbin

This is because I have a file here:

$ cat src/main/java/BuildNumber.properties
build.number=pdurbin

The test passes just fine, which is good! As a developer I should be free to specify a custom build number.

So should this test be here to assure the default app is not shipping a bundle file that's going to override this setting?

No. In fact, we do ship a BuildNumber.properties in each war file. I'm not sure why we would assert that we don't do this but I'm probably misunderstanding what's being discussed above.

In short, I think we should get this into a sprint so core team members can focus on a proper review while it's in a sprint. Again, it sounds like @poikilotherm is ok with the PR as-is. Great.

@pdurbin pdurbin added the Size: 3 A percentage of a sprint. 2.1 hours. label Dec 2, 2022
@mreekie
Copy link

mreekie commented Dec 14, 2022

added to sprint Dec 15, 2022

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

I didn't test this but the code makes sense. Should work! I did tweak the docs.

@kcondon kcondon self-assigned this Dec 16, 2022
@kcondon kcondon merged commit 926e741 into IQSS:develop Dec 16, 2022
@pdurbin pdurbin added this to the 5.13 milestone Dec 16, 2022
@poikilotherm poikilotherm deleted the 7000-mpconfig-version branch May 21, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Code Infrastructure formerly "Feature: Code Infrastructure" Component: Containers Anything related to cloudy Dataverse, shipped in containers. Feature: Developer Guide Size: 3 A percentage of a sprint. 2.1 hours.
Projects
Status: No status
Status: Valuation
Development

Successfully merging this pull request may close these issues.

6 participants