BlockingLoadBalancerClient does not work with KubernetesDiscoveryClient
See original GitHub issueHi,
I’m trying to migrate from ribbon LB to newly introduced blocking LB.
Here is a test replicating the issue:
@Test
public void testReconstructURIForK8S() {
ServiceInstance instance = new KubernetesServiceInstance("auth-server", "auth-server",
new EndpointAddress("hostname", "127.0.0.1", "nodeName", null),
new EndpointPort("http", 8091, "tcp"),
Collections.emptyMap(),
false);
URI uri = LoadBalancerUriTools.reconstructURI(new TruncateSchemaServiceInstance(instance),
URI.create("http://auth-server/oauth/token"));
assertThat(uri.toString()).isEqualTo("http://127.0.0.1:8091/oauth/token");
}
Fails with:
001: "java.lang.IllegalStateException: Could not create URI object: Expected hostname at index 7: http://://127.0.0.1:8091/oauth/token"
002: "at org.springframework.web.util.HierarchicalUriComponents.toUri(HierarchicalUriComponents.java:514)"
003: "at org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools.doReconstructURI(LoadBalancerUriTools.java:111)"
004: "at org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools.reconstructURI(LoadBalancerUriTools.java:95)"
005: "at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.reconstructURI(BlockingLoadBalancerClient.java:75)"
006: "at org.springframework.cloud.client.loadbalancer.ServiceRequestWrapper.getURI(ServiceRequestWrapper.java:43)"
007: "at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:97)"
008: "at org.springframework.cloud.client.loadbalancer.LoadBalancerRequestFactory.lambda$createRequest$0(LoadBalancerRequestFactory.java:61)"
009: "at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.execute(BlockingLoadBalancerClient.java:62)"
The issue is that KubernetesServiceInstance returns for schema either “http://” or “https://”. Current implementation of LoadBalancerUriTools except schema to be “http” or “https”.
I’ve checked implementation of ServiceIntance for Eureka, it returns null when getSchema is called.
Should we fix issue in KubernetesServiceInstance or adjust LoadBalancerUriTools to trim “😕/” during URI reconstruction? (second one looks more safe).
Thanks, Artyom
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Spring Cloud Kubernetes application does not detect when it ...
Here is the application.yml, application-kubernetes.yml, and build.gradle combo that finally worked for me: build.gradle
Read more >spring-cloud.pdf
Github development process, using Github tracker for issues and merging pull ... BlockingLoadBalancerClient is used to create a full physical address.
Read more >KubernetesDiscoveryClient (Spring Cloud Kubernetes
Kubeneretes implementation of DiscoveryClient . Author: Ioannis Canellos. Field Summary. Fields inherited from interface org.springframework.
Read more >Spring Cloud discussion and questions - Gitter
We are having trouble with a eureka client application registering its instance id as "localhost:appName:8080". While troubleshooting the problem, I found a ...
Read more >Microservices With Spring Cloud Kubernetes - Piotr's TechBlog
To deploy and run applications on Kubernetes we don't have to add anything into a source code. The orchestration and configuration is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wait, why can’t we fix kubernetes service instance? I don’t want work around in a common library for this one’s bug.
Hi, @TYsewyn @spencergibb Are we waiting for next major release to get it merged?
Thanks