question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlockingLoadBalancerClient does not work with KubernetesDiscoveryClient

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
spencergibbcommented, Jan 8, 2020

Wait, why can’t we fix kubernetes service instance? I don’t want work around in a common library for this one’s bug.

0reactions
ArtyomGabeevcommented, Feb 7, 2020

Hi, @TYsewyn @spencergibb Are we waiting for next major release to get it merged?

Thanks

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found