Skip to content

Conversation

@ryanjbaxter
Copy link
Contributor

Fixes #2085

Copy link

Copilot AI left a 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.

@ryanjbaxter ryanjbaxter force-pushed the leaderinfocontributor-enable/disable branch from 81743a4 to 4ec9c18 Compare October 29, 2025 18:50
@ryanjbaxter ryanjbaxter merged commit 1b659d7 into spring-cloud:3.2.x Oct 29, 2025
21 of 33 checks passed
}
----

You can disable this `InfoContributor` by setting `management.info.leade.enabled`
Copy link

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

Copy link
Contributor Author

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 {
Copy link

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);

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot disable leaderElection for /info endpoint

4 participants