Skip to content

KubernetesReactiveDiscoveryClient cache configuration issues #1641

@habelson

Description

@habelson

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:

  1. DefaultKubernetesServiceInstance is not Serializable, preventing some caching implementations from functioning correctly by default
  2. JSON Serialization of DefaultKubernetesServiceInstance fails 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.
  3. With spring.cloud.kubernetes.loadbalancer.mode=POD the cached value of the discovered services is the POD address which changes on redeploy, and there is nothing setup to invalidate the cache.
  4. 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions