-
Notifications
You must be signed in to change notification settings - Fork 1k
Add the ability to disable leader info contributor #2086
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
Add the ability to disable leader info contributor #2086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the ability to disable the LeaderInfoContributor via configuration property, allowing users to prevent leader election information from being exposed in the /actuator/info endpoint when not desired.
- Adds
@ConditionalOnEnabledInfoContributor("leaderelection")to the bean definition - Adds test coverage for the disabled state
- Updates existing test to use more specific JSON path assertions
- Documents the new configuration option
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Fabric8LeaderAutoConfiguration.java | Adds conditional annotation to control LeaderInfoContributor bean creation |
| Fabric8LeaderInfoContributorDisabledTests.java | New test class verifying the contributor can be disabled |
| Fabric8LeaderAutoConfigurationTests.java | Updated test with more specific JSON path assertions instead of string containment |
| leader-election.adoc | Adds documentation for the new configuration property |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...java/org/springframework/cloud/kubernetes/fabric8/leader/Fabric8LeaderAutoConfiguration.java
Outdated
Show resolved
Hide resolved
81743a4 to
4ec9c18
Compare
| } | ||
| ---- | ||
|
|
||
| You can disable this `InfoContributor` by setting `management.info.leade.enabled` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an typo, correct? Should be
management.info.leader.enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I fixed the typo!
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
| properties = { "spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.leader.autoStartup=false", | ||
| "management.info.leader.enabled=false" }) | ||
| class Fabric8LeaderInfoContributorDisabledTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have a test, when management.info.defaults.enabled=false that you also get
context.getBean(LeaderInfoContributor.class))
.isInstanceOf(NoSuchBeanDefinitionException.class);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need that. That is functionality from Boot which controls all InfoContributors.
Fixes #2085