spring-cloud / spring-cloud/spring-cloud-commons

Kubernetes Discovery Client + Cloud Load Balancer WebClient Issue

Open
#1,094 0 comments 0 reactions 1 assignee View on GitHub

@OlgaMaciaszek is already working on this.

Since Jun 10, 2022.

in progress
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Description

A Spring Boot project with spring-cloud-starter-kubernetes-discoveryclient and spring-cloud-starter-loadbalancer enabled is unable to communicate with a spring-cloud-kubernetes-discoveryserver.

If spring-cloud-starter-loadbalancer is removed from the classpath, the KubernetesReactiveDiscoveryClient is able to successfully communicate with the discovery server.

It seems that spring-cloud-starter-loadbalancer modifies the WebClient.Builder by adding a Load Balancer exchange filter and it is now unable to communicate with the discovery server with a Media Type Exception.

2022-04-13 20:40:03.165 ERROR 1 --- [     parallel-1] scoveryClientServiceInstanceListSupplier : Exception occurred while retrieving instances for service spring-cloud-kubernetes-discoveryserver

org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/octet-stream' not supported for bodyType=org.springframework.cloud.kubernetes.discovery.KubernetesServiceInstance
	at org.springframework.web.reactive.function.BodyExtractors.lambda$readWithMessageReaders$12(BodyExtractors.java:201) ~[spring-webflux-5.3.18.jar:5.3.18]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpoint ? Body from UNKNOWN  [DefaultClientResponse]

I couldn't find a straightforward way to modify the WebClient so it would be able to successfully communicate with the discovery server, are there any insights here?

Thank you

Sample

This repository includes an application and a Kubernetes deployment script along with a README with more details about building and reproducing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.