Skip to content

3.0.0-M5: JMX Endpoint Exposure #444

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

Closed
1 task
Tracked by #440
fabapp2 opened this issue Sep 27, 2022 · 16 comments · Fixed by #473
Closed
1 task
Tracked by #440

3.0.0-M5: JMX Endpoint Exposure #444

fabapp2 opened this issue Sep 27, 2022 · 16 comments · Fixed by #473
Assignees
Labels
3.0.0 Spring Boot 3.0.0 good first issue Good for newcomers type: enhancement New feature or request upgrade:boot-report
Milestone

Comments

@fabapp2
Copy link
Contributor

fabapp2 commented Sep 27, 2022

From the Release Notes

By default, only the health endpoint is now exposed over JMX, to align with the default web endpoint exposure. This can be changed by configuring the management.endpoints.jmx.exposure.include and management.endpoints.jmx.exposure.exclude properties.

What needs to be done

To guarantee that JMX endpoint exposure is exactly the same as prior to 3.0 the settings in 2.7 should be restored and the user should be warned about the implications and how to secure JMX endpoints.

Report

Condition

Application is a Spring Boot 3.0.0 application and management.endpoints.jmx.exposure.include is not set.

Section

By default, only the health endpoint is now exposed over JMX, to align with the default web endpoint exposure. This can be changed by configuring the management.endpoints.jmx.exposure.include and management.endpoints.jmx.exposure.exclude properties.
As Spring Boot Migrator can't tell if the JMX endpoints provided in 2.7 are used, the recipe will restore the defaults as in 2.7 by setting management.endpoints.jmx.exposure.include=*. This exposes all management endpoints over JMX. To provide only required information over JMX we strongly recommend to configure the management.endpoints.jmx.exposure.include property to your specific needs and only expose required JMX endpoints.
Please consult the reference documentation Spring Boot 3.0.0-M5 or after 3.0.0 is GA: Spring Boot 3.0.0

Recipe

Condition

Application is a Spring Boot 3.0.0 application and management.endpoints.jmx.exposure.include is not set.

Action

  • Set management.endpoints.jmx.exposure.include=* in application.properties
@fabapp2 fabapp2 changed the title JMX Endpoint Exposure 3.0.0-M5: JMX Endpoint Exposure Sep 27, 2022
@fabapp2 fabapp2 added this to the v0.13.0 milestone Sep 27, 2022
@ishu-thakur
Copy link
Contributor

Hi @fabapp2 , i would like to work on this one .
so you want me to set management.endpoints.jmx.exposure.include=* in every single or all application.properties that exist in the spring-boot-migrator or there is some specific ones in which you want me to set that ?

@fabapp2
Copy link
Contributor Author

fabapp2 commented Sep 28, 2022

Hi @ishu-thakur,

thank you for your picking this issue! 🚀

As application.yaml/application.properties contain the properties for 'default' profile (which properties will be used until overwritten by a properties in another profile) it should be enough to set the property there. If more than one application.properties/.yaml exists it should be set in all of them (hard to calculate if they are ending up in digferent deployables) which should be sufficient.
It is important to inform the user about the implications (especially as it is security related), therefor the report.

Please also see #446
(feedback appreciated, as always)

Thanks again for picking this!
Please don't hesitate to ask questions and provide feedback.

@ishu-thakur
Copy link
Contributor

Hi @fabapp2 tell me if i'm wrong , so the thing I have to do is that management.endpoints.jmx.exposure.include=* in the application.properties where we are setting the profile 'default' as it will override the the property if present in the other application.properties ? Sry i am asking question as i'm new contributor so I want to get the clarity for it .

@fabapp2
Copy link
Contributor Author

fabapp2 commented Sep 28, 2022

Hi @ishu-thakur

It's great you ask to clarify!
The issue consists of basically two "things".

  1. Creating a report, see the Report in the issue and additionally the Contributing Spring Boot 3.0.0 Upgrade recipes #446 discussion where I linked an example implementation. A report consists of multiple sections and these sections can be created like in the example classes.
  2. Then there's the recipe (the automation you're asking about). The access to properties is abstracted by SpringBootApplicationPropertieswhich can be retrieved from the ProjectContext using a Finder, here SpringBootApplicationPropertiesResourceListFilter (the name should be changed to SpringBootApplicationPropertiesResourceListFinder). The SpringBootApplicationProperties provides the API to add the property to the default properties. (Yaml will be abstracted as well, just not there yet)

Creating the report should be straightforward looking at the linked example classes. 🤞

For the migration recipe:

  • Create a new Boot_27_30_JmxEndpointExposureAction extending AbstractAction and implement the mentioned logic there
  • Implement the condition as described in the issue (or reuse the one from the report if possible)
  • Provide a test using TestProjectContext if possible for single and multi-module projects
  • Add the new Action to the recipe declaration in boot-2.7-3.0-dependency-version-update.yaml
  • Add the migration to the BootUpgrade_27_30_... integration tests, e.g. BootUpgrade_27_30_ManuallyManaged_IntegrationTest

As I mentioned, feel free to ask anything anytime. You can also provide a draft PR in case you have questions or need feedback early on.

Hope this was helpful?

@DevPJ9
Copy link

DevPJ9 commented Sep 30, 2022

Hello @fabapp2 I would also like to work on this issue and will be syncing with @ishu-thakur for this issue.

@fabapp2
Copy link
Contributor Author

fabapp2 commented Sep 30, 2022

Hello @fabapp2 I would also like to work on this issue and will be syncing with @ishu-thakur for this issue.

Hi @DevPJ9,
thanks for your interest. 🚀
If you know @ishu-thakur and want to pair on this (or sync by other means), totally fine.
Otherwise, I'd think you'll probably step on each other's toes and it might make sense to pick something else.
If you're uncertain how to contribute I am more than happy to help you out and get you started.

@DevPJ9
Copy link

DevPJ9 commented Sep 30, 2022

Hello @fabapp2.I know @ishu-thakur and will be able to sync with him. Thanks for your suggestion and support.

@ishu-thakur
Copy link
Contributor

@fabapp2 I am little uncertain how to contribute can you help me with it ? and Apologies for the late reply from my side 🙏 .

@fabapp2
Copy link
Contributor Author

fabapp2 commented Oct 7, 2022

Hi @ishu-thakur
let me add some information to #446.
Could you let me know if I missed something you need to know?

@ishu-thakur
Copy link
Contributor

ishu-thakur commented Oct 8, 2022

@fabapp2 is there any documentation that tell how we can run the project or file to test the logic for JMX endpoint exposure i have created as the test case file doesn't seems to runnable :( . And i think the new Action will go to boot-2.7-3.0-upgrade-report.yaml instead boot-2.7-3.0-dependency-version-update.yaml .

Do i have to create a condition under org.springframework.sbm.boot.upgrade_27_30.conditions for it too ?

@fabapp2
Copy link
Contributor Author

fabapp2 commented Oct 8, 2022

Hi @ishu-thakur
Thanks for asking these questions!
Your questions highlighted more missing bits in #446
I will answer your questions there, hoping it's helpful for others.

@fabapp2
Copy link
Contributor Author

fabapp2 commented Oct 8, 2022

Hi @ishu-thakur
I added links to some resources and documentation.
Please let me know if you miss something.
This issue goes in both, report and upgrade part and has two separate components.
#446 links a simple example for the report part under "Report", you don't need to touch the yaml here.
The migration bit will require you to implement the property change for single and multi-module applications in a new Action extending from AbstractAction.

Here it could be done like this (🤞):

// get spring boot application property files
List<SpringBootApplicationProperties> applicationProperties = context.search(
                new SpringBootApplicationPropertiesResourceListFilter());
         
applicationProperties.stream()
                // filter the properties files for default profile
                .filter(p -> p.isDefaultProperties())
                // and add the property
                .forEach(p -> p.setProperty("...", "..."));

For The Action (migration) you'll need to provide a condition (and reference it in yaml) in the package you named.
For the report there's the concept of Finders which can be used as condition (and thus be used for report and migration).
These provide the matches and if there are no matches it's not applicable.

The migration bit can be tested by creating a ProjectContext using TestProjectContext and passing it to the Action under test and then verify the modification through the ProjectContext.

If you like you can just create a draft PR with what you have and I can answer questions and provide feedback on concrete code, might be easier.

@fabapp2
Copy link
Contributor Author

fabapp2 commented Oct 10, 2022

@ishu-thakur you must add

.addRegistrar(new SpringBootApplicationPropertiesRegistrar(new SpringApplicationPropertiesPathMatcher()))

to make TestProjectContext init the SpringBootApplicationProperties

@fabapp2 fabapp2 linked a pull request Oct 11, 2022 that will close this issue
@ishu-thakur
Copy link
Contributor

SpringBootApplicationProperties

@fabapp2 while i am writing the testcase for the jmx exposure ? then i should add .addRegistrar(new SpringBootApplicationPropertiesRegistrar(new SpringApplicationPropertiesPathMatcher())) ?

@fabapp2
Copy link
Contributor Author

fabapp2 commented Oct 28, 2022

SpringBootApplicationProperties

@fabapp2 while i am writing the testcase for the jmx exposure ? then i should add .addRegistrar(new SpringBootApplicationPropertiesRegistrar(new SpringApplicationPropertiesPathMatcher())) ?

Sorry for my late reply,
I was on vacation and am a bit behind at the moment.

Correct, otherwise "specialized resource" SpringApplicationProperties will not be found by the Finder

@ishu-thakur
Copy link
Contributor

@fabapp2 its okay I hope you have enjoyed your vacation :) yes let me figure it out and make changes then .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0.0 Spring Boot 3.0.0 good first issue Good for newcomers type: enhancement New feature or request upgrade:boot-report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants