Skip to content

Move fabric8 discovery to listers#2133

Merged
ryanjbaxter merged 40 commits intospring-cloud:mainfrom
wind57:move-fabric8-discovery-to-listers
Feb 11, 2026
Merged

Move fabric8 discovery to listers#2133
ryanjbaxter merged 40 commits intospring-cloud:mainfrom
wind57:move-fabric8-discovery-to-listers

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Feb 2, 2026

No description provided.

wind57 added 13 commits February 2, 2026 23:40
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
}

@Bean
@ConditionalOnMissingBean
Copy link
Contributor Author

@wind57 wind57 Feb 5, 2026

Choose a reason for hiding this comment

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

we used to create this one in place where needed, but then I noticed that in the k8s-client native, we create in the auto-configuration. So I decided to do it in the fabric8 case too.

Also, it simplifies testing a lot, having it as a Bean

LogFactory.getLog(Fabric8AbstractBlockingDiscoveryClient.class));

private final KubernetesDiscoveryProperties properties;
private final List<Lister<Service>> serviceListers;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Listers and Informers here, just like the case for the k8s-native client. Unlike the native client, we don't have to deal with SharedInfomerFactory, so a bit simpler


List<Endpoints> allEndpoints = endpoints(properties, client, namespaceProvider, "fabric8-discovery", serviceId,
predicate);
List<Service> allServices = serviceListers.stream()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a 1-1 mapping with k8s-native, meaning we do things the same here, much easier to reason like this

Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
Signed-off-by: wind57 <eugen.rabii@gmail.com>
assertThat(BASIC_JSON_TESTER.from(healthResult))
.extractingJsonPathArrayValue("$.components.discoveryComposite.components.discoveryClient.details.services")
.containsExactlyInAnyOrder("kubernetes", "busybox-service");
.contains("kubernetes", "busybox-service", "service-wiremock");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we changed to look in all namespaces and there are a few more services present that we do not care about ( like metrics ), so instead use contains

Signed-off-by: wind57 <eugen.rabii@gmail.com>
@wind57
Copy link
Contributor Author

wind57 commented Feb 10, 2026

@ryanjbaxter can you trigger copilot for a review here please?

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 pull request migrates the fabric8 discovery client implementation from direct Kubernetes API calls to using informers and listers for improved performance and reduced API server load. The changes involve refactoring the discovery client to work with cached data from shared index informers rather than making real-time API calls for service discovery.

Changes:

  • Introduced Fabric8InformerAutoConfiguration to manage shared index informers and listers for Services and Endpoints
  • Refactored Fabric8DiscoveryClient and related classes to use listers instead of direct Kubernetes API calls
  • Updated test files to properly mock informers and listers, removing old WireMock-based approaches
  • Added lifecycle management (@PostConstruct/@PreDestroy) for informer resources

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Fabric8InformerAutoConfiguration.java New configuration class that creates and manages shared index informers and listers
Fabric8DiscoveryClient.java Updated to accept listers and informers instead of making direct API calls
Fabric8AbstractBlockingDiscoveryClient.java Core refactoring to use listers for service discovery with proper lifecycle management
Fabric8DiscoveryClientUtils.java Removed deprecated methods, added informer creation utilities
TestAssertions.java Added await logic for eventual consistency in tests
Multiple test files Migrated from WireMock to KubernetesMockServer with informer-based testing
Fabric8AutoConfiguration.java Added KubernetesNamespaceProvider bean

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wind57 wind57 marked this pull request as ready for review February 10, 2026 18:45
@wind57 wind57 marked this pull request as draft February 10, 2026 18:47
Signed-off-by: wind57 <eugen.rabii@gmail.com>
@wind57
Copy link
Contributor Author

wind57 commented Feb 10, 2026

copilot has no complaints? I think it just stopped abruptly, because the review is for 45 files, but only a few have summary details. Can I ask for a re-trigger? I don't if you have the free quota or not...

@wind57 wind57 marked this pull request as ready for review February 10, 2026 19:56
@ryanjbaxter ryanjbaxter requested a review from Copilot February 10, 2026 20:01
@ryanjbaxter
Copy link
Contributor

It says it reviewed everything but I retriggered it

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

Copilot reviewed 45 out of 45 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: wind57 <eugen.rabii@gmail.com>
@wind57
Copy link
Contributor Author

wind57 commented Feb 10, 2026

@ryanjbaxter this is ready now, and closes this issue : #2118 I tried to be careful not to have breaking changes, but it helped a lot when we made things far less reachable last year.

@ryanjbaxter ryanjbaxter added this to the 5.0.2 milestone Feb 11, 2026
@ryanjbaxter ryanjbaxter merged commit c887875 into spring-cloud:main Feb 11, 2026
26 checks passed
@ryanjbaxter ryanjbaxter linked an issue Feb 11, 2026 that may be closed by this pull request
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.

k8s client vs fabric8 discovery implementation

3 participants