Add the ability to disable leader info contributor#2086
Conversation
There was a problem hiding this comment.
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.
Here is an typo, correct? Should be
management.info.leader.enabled
There was a problem hiding this comment.
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.
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.
I am not sure we need that. That is functionality from Boot which controls all InfoContributors.
Fixes #2085