-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
Spring Cloud 2023.0.1 (and prior)
We have an ecosystem of spring boot microservices, some are reactive and some are blocking. Some have their own need for caching and some don't. We have run into an issue with the presence of the @Cacheable annotation in KubernetesReactiveDiscoveryClient in reactive microservices that have @EnableCaching for their own purposes.
This has surfaced as several issues:
DefaultKubernetesServiceInstanceis notSerializable, preventing some caching implementations from functioning correctly by default- JSON Serialization of
DefaultKubernetesServiceInstancefails by default because the properties discovered by the getters don't match whats available in the constructor. This requires configuring the ObjectMapper to ignore unknown properties. - With
spring.cloud.kubernetes.loadbalancer.mode=PODthe cached value of the discovered services is the POD address which changes on redeploy, and there is nothing setup to invalidate the cache. - The blocking implementation of KubernetesDiscoveryClient does not have the same use of @Cacheable and therefore has different behavior from its reactive counterpart
While I'm not convinced there is necessarily a bug here, I am concerned on the lack of documentation. What sort of cache configuration is expected to be in place (backend library, TTL, etc) for the reactive discovery client to behave as intended? Additionally, was the caching behavior in the reactive version of the class intended to be different from the blocking version?