These are chat archives for spring-cloud/spring-cloud

27th
Feb 2018
Kent Johnson
@kentoj
Feb 27 2018 00:22
I see this issue as a starting point for adding CORS for SCG. Is there an easier way?
Spencer Gibb
@spencergibb
Feb 27 2018 00:30
@kentoj you can create a custom netty HttpClient bean
Kent Johnson
@kentoj
Feb 27 2018 00:32
Ok, I'll try that. Can you point me to any good examples? A quick google search doesn't bring anything up.
Spencer Gibb
@spencergibb
Feb 27 2018 00:42
there are none
One of my goals before GA
Kent Johnson
@kentoj
Feb 27 2018 00:42
Ok, I was thinking so. Right.
Do you need any help with some of these things? When is the GA date? Maybe I can contribute.
Spencer Gibb
@spencergibb
Feb 27 2018 00:44
Late March. Yeah, if you get some of these things working, we could use them as a basis for samples.
Kent Johnson
@kentoj
Feb 27 2018 00:44
I got everything working except for TLS and CORS.
I'd love to help write some samples. I am writing everything in Kotlin, so it probably wouldn't be hard to do some in Java as well.
Spencer Gibb
@spencergibb
Feb 27 2018 00:45
we're currently working on a release. TLS would be next for me
Kent Johnson
@kentoj
Feb 27 2018 00:46
Ok, I see. Would it be helpful for me to write up some examples on integrating with Eureka Client in YML and code (Java & Kotlin)?
Kent Johnson
@kentoj
Feb 27 2018 00:52
So I'll stick with Zuul then for my current production stack. I am really looking forward to using SCG especially for the websocket proxying.
Kent Johnson
@kentoj
Feb 27 2018 01:14
Actually, I was able to get everything working but CORS with TLS in an NGINX proxy.
If I could just get CORS working then I am good to go.
Spencer Gibb
@spencergibb
Feb 27 2018 01:31
cool, CORS shouldn't be too tricky
Kent Johnson
@kentoj
Feb 27 2018 01:32
Right, I just realized I can just add the headers with some filters, which I also just now did.
As long as that works for me then I am going to production tomorrow morning with SCG!
This is cool. Just the week before I am giving a meetup talk on SCG and Spring Cloud with Docker I get all the latest versions working. Awesome!
Spencer Gibb
@spencergibb
Feb 27 2018 01:33
Sweet. I'd love to see it!
I am hoping there is some timeout config for SCG. Headed to the docs now.
Spencer Gibb
@spencergibb
Feb 27 2018 01:34
Nice, I've been there a few times, though I'm in michigan now.
timeout for what?
Kent Johnson
@kentoj
Feb 27 2018 01:34
Like the Hystrix timeout in Zuul. Basic request timeout.
Spencer Gibb
@spencergibb
Feb 27 2018 01:36
There's two ways to do it the Hystrix filter. or configure the timeouts on the netty HttpClient (which involves a bean definition).
Kent Johnson
@kentoj
Feb 27 2018 01:36
Ok, cool, I'll look into that.
Kent Johnson
@kentoj
Feb 27 2018 01:45
I am trying to work my way through it. I see the hystrix(HystrixObservableCommand.Setter) method but am struggling constructing the object with the properties I need. I can make a HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(1000) yet I don't know how to pass that to the hystrix(...) filter.
Also, what is a HystrixCommandGroup and how does that map to the old style config:
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: ${timeouts.request-timeout-millis}
    districts:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: ${timeouts.request-timeout-millis}
    uaa-service:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: ${timeouts.request-timeout-millis}
Spencer Gibb
@spencergibb
Feb 27 2018 01:48
if you just use the command name version, that maps to districts or uaa-service
Kent Johnson
@kentoj
Feb 27 2018 01:48
I think I got it. Does this look right:
HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("default"))
                .andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(1000))
Where default could be default, districts, or uaa-service in my case?
So this makes my route locator builder look like this:
@Bean
    fun customRouteLocator(builder: RouteLocatorBuilder): RouteLocator {
        val config = HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("default"))
                .andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
                        .withExecutionTimeoutInMilliseconds(1000)
                        .withExecutionTimeoutEnabled(true))

        return builder.routes {
            route(id = "uaaservice") {
                path("/uaa/**")
                filters {

                    hystrix(config)
                }
                uri("lb://uaa-service")
            }
        }
    }
Abhishek Dujari
@abshkd
Feb 27 2018 06:39
i am getting terrible performance from zuul on AWS. the gateway itself is quite ok but when forwarding requests it is slow. I hunted and googled and found this
ribbon:
    okhttp:
        enabled: true
do i need to some dependency for using okhttp?
i mean how can i even begin to fix this performance issue. The instances just become non-responsive failing healthcheck. there is no issue with resources on the instance. at this points its just cascade failure
Haruhiko Nishi
@hanishi
Feb 27 2018 06:42
Hi, I have problem with Eureka Client enabled instances, each deployed to a random container by SCDF server, whose eureka.instance.instanceId property is set to ${spring.cloud.client.hostname}:${spring.application.name}:${random.value}
Every time these instances get"refreshed" via Spring Cloud Bus, they register themselves with Eureka Server with a new ${random.value}
I tried ${server.port} instead of ${random.value}, but the value is always 0.
Is there some unique ID that can be used to generate unique eureka.instance.instanceId that is not affected by refresh?
Abhishek Dujari
@abshkd
Feb 27 2018 06:42
we have 3 instances up and they all fail at about 50 clients
Abhishek Dujari
@abshkd
Feb 27 2018 07:03
i can reproduce the issue. If any forward request to microservice or proxied route is slow, everything will fail
max number of clients is like 50
Haruhiko Nishi
@hanishi
Feb 27 2018 07:08
It’s related to spring-cloud/spring-cloud-netflix#843 but the random.id does change as aforementioned which causes invoking Spring Cloud Bus endpoint via ribbon client fail.
Abhishek Dujari
@abshkd
Feb 27 2018 07:20
is isolation strategy semaphore default for Zuul? how do i make it threads
Abhishek Dujari
@abshkd
Feb 27 2018 07:59
When I put Edgeware.SR2 in my spring-cloud-dependencies version, it cannot be found.
autocomplete also only shows me upto Dalton which is what I was using
i see the actual issue
Non-resolvable import POM: Failure to find org.springframework.cloud:spring-cloud-dependencies:pom:Edgeware.SR2 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 116, column 25
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-zuul:jar is missing. @ line 397, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter:jar is missing. @ line 411, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-ribbon:jar is missing. @ line 415, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-hystrix:jar is missing. @ line 427, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-spectator:jar is missing. @ line 431, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-eureka:jar is missing. @ line 439, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-config:jar is missing. @ line 443, column 21
[ERROR] 'dependencies.dependency.version' for org.springframework.cloud:spring-cloud-starter-feign:jar is missing. @ line 447, column 21
Abhishek Dujari
@abshkd
Feb 27 2018 08:04
you see i have typo :/
Edgeware
Haruhiko Nishi
@hanishi
Feb 27 2018 09:18
${spring.cloud.client.hostname}:${spring.application.name}:${SPRING_APPLICATION_INDEX} This worked
Haruhiko Nishi
@hanishi
Feb 27 2018 11:15
@dsyer
Hi, would you be able to tell me why does the application instance shuts itself down after refresh is invoked?
2018-02-27 20:01:57.352  INFO 11379 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EULER-HTTPCLIENT-PROCESSOR-KAFKA/testhost2.euler:euler-httpclient-processor-kafka:3 - registration status: 204
2018-02-27 20:01:58.746  INFO 11379 --- [      Thread-18] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@29f69090: startup date [Tue Feb 27 19:59:17 JST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1b0375b3
2018-02-27 20:01:58.747  INFO 11379 --- [      Thread-18] o.s.c.n.e.s.EurekaServiceRegistry        : Unregistering application euler-httpclient-processor-kafka with eureka with status DOWN
2018-02-27 20:01:58.747  WARN 11379 --- [      Thread-18] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1519729318747, current=DOWN, previous=UP]
2018-02-27 20:01:58.748  INFO 11379 --- [      Thread-18] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@58b5a2f3: startup date [Tue Feb 27 19:59:39 JST 2018]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@29f69090
2018-02-27 20:01:58.748  INFO 11379 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EULER-HTTPCLIENT-PROCESSOR-KAFKA/testhost2.euler:euler-httpclient-processor-kafka:3: registering service...
2018-02-27 20:01:58.748  INFO 11379 --- [      Thread-18] o.s.c.n.e.s.EurekaServiceRegistry        : Unregistering application euler-httpclient-processor-kafka with eureka with status DOWN
2018-02-27 20:01:58.751  INFO 11379 --- [      Thread-18] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647
2018-02-27 20:01:58.751  INFO 11379 --- [      Thread-18] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147482647
2018-02-27 20:01:58.752  INFO 11379 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EULER-HTTPCLIENT-PROCESSOR-KAFKA/testhost2.euler:euler-httpclient-processor-kafka:3 - registration status: 204
Dave Syer
@dsyer
Feb 27 2018 11:17
No idea.
Maybe you don't have any non-daemon threads?
Is it a web app?
Haruhiko Nishi
@hanishi
Feb 27 2018 11:18
It's a Processor and it is a web app(httpclient with some customization) deployed from SCDF
Does Eureka kills client?
Dave Syer
@dsyer
Feb 27 2018 11:19
Its impossible to say with just a log snippet
Kind of looks like it's not a webapp
Haruhiko Nishi
@hanishi
Feb 27 2018 11:23
It's a Spring Cloud Stream app(starts tomcat, so it's a web app?) with Eureka Client
Dave Syer
@dsyer
Feb 27 2018 11:23
I guess you need to provide more detail then. Steps to reproduce. A sample app maybe?
What version of Spring Cloud Stream are you using?
Haruhiko Nishi
@hanishi
Feb 27 2018 11:26
<parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-build</artifactId>
        <version>1.3.7.RELEASE</version>
        <relativePath/>
</parent>
Dave Syer
@dsyer
Feb 27 2018 11:27
spring-cloud-build isn't telling me anything
Where's the code?
It's not a @SpringBootApplication?
Really it would be a lot easier if you just put the code in github
Haruhiko Nishi
@hanishi
Feb 27 2018 11:30
It is a spring boot applicaiton

@SpringBootApplication
@EnableDiscoveryClient
@Import(org.springframework.cloud.stream.app.euler.httpclient.processor.EulerHttpclientProcessorConfiguration.class)
public class EulerHttpclientProcessorKafka10Application {

    public static void main(String[] args) {
        SpringApplication.run(EulerHttpclientProcessorKafka10Application.class, args);
    }
}
Do I need to make it public?
Dave Syer
@dsyer
Feb 27 2018 11:31
Make what public?
Haruhiko Nishi
@hanishi
Feb 27 2018 11:31
my code?
Dave Syer
@dsyer
Feb 27 2018 11:31
If you make the code public that would certainly help
Problem:
Thread-18(in the log above) is terminating itself and that is resulting new container to launch
Dave Syer
@dsyer
Feb 27 2018 11:37
It's a private repo
Can you make a public repo which reproduces the problem? That way other people can see.
Haruhiko Nishi
@hanishi
Feb 27 2018 11:44
To reproduce problem it needs to be deployed to Yarn cluster
In standalone environment it does not happen
Also, it happens occasionally. Some containers survive with refresh but if it doesn't a new container is launched
Dave Syer
@dsyer
Feb 27 2018 11:46
I guess it's a Yarn problem then.
Ask in the dataflow channel?
Haruhiko Nishi
@hanishi
Feb 27 2018 11:47
There is dataflow channel?
Haruhiko Nishi
@hanishi
Feb 27 2018 11:47
Thank you!
Haruhiko Nishi
@hanishi
Feb 27 2018 12:16
Isn’t there any paid support?
Dave Syer
@dsyer
Feb 27 2018 12:17
I'm sure there is
This is an open forum though
Haruhiko Nishi
@hanishi
Feb 27 2018 12:20
Would it be like $200/hour thing?
Dave Syer
@dsyer
Feb 27 2018 12:20
No idea. Not my department.
Abhishek Dujari
@abshkd
Feb 27 2018 12:20
yeah unfortunately @dsyer is well known only for free support :D
Dave Syer
@dsyer
Feb 27 2018 12:21
These people take payment: https://support.pivotal.io/. Not sure if they take credit cards.
Abhishek Dujari
@abshkd
Feb 27 2018 12:27
@dsyer whats the recommended version for spring-cloud right now? I am using Edgware.RELEASE
i had a bunch of issues with forwarded requests causing complete cascading failure of all zuul instances. when I changed from Dalston.sr2 to the above things appear to be more stable. I can't really tell what the changelog is
on a high level
Abhishek Dujari
@abshkd
Feb 27 2018 12:34
@dsyer https://engineering.riotgames.com/news/riot-games-api-fulfilling-zuuls-destiny I have this exact problem but I am out of ideas.
tl;dr when there are enough slow forwarded requests (like 1000 rpm and only 20 clients per instance) , Zuul will block and even healthcheck endpoint will not respond. I have been using an xlarge
resource is not an issue.
Latest is Edgware.SR2
Abhishek Dujari
@abshkd
Feb 27 2018 12:55
thank you
i still cannot explain why we have terrible performance. nay sayers want to move to some Api gateway as a service eventually
Dave Syer
@dsyer
Feb 27 2018 13:00
If you can reproduce the problem someone can help you analyse it
It's probably just thread pools filling up though
WHich you can only fix by using more resourecs.
API gateways do not solve that kind of issue. You just punt it to someone else.
Abhishek Dujari
@abshkd
Feb 27 2018 13:49
@dsyer I can reproduce the issue fairly easily
Dave Syer
@dsyer
Feb 27 2018 13:51
Great. Put the code in github with a nice README.
Abhishek Dujari
@abshkd
Feb 27 2018 13:51
ill work on that and post back with the code. It;s definitely thread pools but I am not familiar with threads and how to check this. also how to check resource allocation so I can have enough threads?
Kent Johnson
@kentoj
Feb 27 2018 16:39
Anyone had success proxying websockets through TLS with Spring Cloud Gateway (SCG)? I am researching that at the moment. I am going through two layers of proxies at the moment the first being NGINX for TLS termination and the second being SCG before the websocket connection hits my service.
Kent Johnson
@kentoj
Feb 27 2018 19:17
@spencergibb I got timeouts working with SCG! It was easy as long as I knew I was supposed to include the compile('io.reactivex:rxjava-reactive-streams:1.2.1') manually in order to get the HystrixGatewayFilterFactory Bean created.
Spencer Gibb
@spencergibb
Feb 27 2018 19:23
@kentoj spring-cloud-starter-netflix-hystrix includes rxjava-reactive-streams
Kent Johnson
@kentoj
Feb 27 2018 19:24

Ok, I didn't have that in my dependencies somehow. I used a starter project from start.spring.io and just got

compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-webflux')
    compile('org.springframework.cloud:spring-cloud-starter-gateway')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
    compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    compile("org.jetbrains.kotlin:kotlin-reflect")

I was probably supposed to check one more box

Spencer Gibb
@spencergibb
Feb 27 2018 19:26
yup, they hystrix one
Kent Johnson
@kentoj
Feb 27 2018 19:27
Works great.
Is there a newer version or different solution to ConfigurationProcessing in spring rather than classpath 'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE'
Spencer Gibb
@spencergibb
Feb 27 2018 19:44
I don't know what that is
Kent Johnson
@kentoj
Feb 27 2018 19:45
That's what I found as a way to get @ConfigurationProperties working. It's not a big issue for me so I'll check into it later if nothing comes to mind.
Spencer Gibb
@spencergibb
Feb 27 2018 19:45
I'd love to see your code after your meetup
Kent Johnson
@kentoj
Feb 27 2018 20:47
Definitely. I'll be posting a demo to Github once I get a chance, hopefully before Thursday at 6.
Kent Johnson
@kentoj
Feb 27 2018 22:10
There is some odd behavior with Spring Cloud Gateway. Response status is 200 when there is no instance available from the load balancer where it seems the response status should be 4xx or 5xx or some error response.
Eugene
@Hronom
Feb 27 2018 22:11

Guys, I'm use FeignClient and ResponseEntity as return type for my method call:

@FeignClient(value = "test-service", decode404 = true)
public interface TestServiceClient {
    @PostMapping(value = "/testItems", consumes = MediaTypes.HAL_JSON_VALUE)
    ResponseEntity<Resource<TestItem>> create(TestItem testItem);

    @GetMapping(value = "/testItems", consumes = MediaTypes.HAL_JSON_VALUE)
    ResponseEntity<Resources<TestItem>> findAll();

    @GetMapping(value = "/testItems/{id}", consumes = MediaTypes.HAL_JSON_VALUE)
    ResponseEntity<Resource<TestItem>> findOne(@PathVariable("id") String id);
}

But I'm still getting exception if method create on back-end side return code 400, wich in my app means that validation not passed. (I'm use spring data rest validator).
How to make ResponseEntity filled without exceptions?

Why when you use ResponseEntity this behaviour not default?
Also added comment to this issue with expected behaviour spring-cloud/spring-cloud-netflix#318 it's pretty annoying...
Spencer Gibb
@spencergibb
Feb 27 2018 22:17
Pull requests welcome
@kentoj what version are you using?
Kent Johnson
@kentoj
Feb 27 2018 22:21
Wait, maybe not.
Spring cloud version: Finchley.BUILD-SNAPSHOT
Spring Boot 2.0.0.RC2
Spencer Gibb
@spencergibb
Feb 27 2018 22:22
We just released Finchley.M7 to go with RC2 BTW
I get a 500 error when there are no instances
Kent Johnson
@kentoj
Feb 27 2018 22:22
Ok, great, I'll upgrade to that
So I have everything working now except when I hit from a JS client I get Invalid CORS request. When I hit it from Postman everything works. I am debugging the Reactive CORS processing code now.
Eugene
@Hronom
Feb 27 2018 22:50
It looks like problem with feign client not on spring side but on side of openfeign, and it looks like this here /feign/SynchronousMethodHandler.java:137 must be added flag to determine what do with other codes.
@spencergibb it seems like you also work in OpenFeign project right?
Kent Johnson
@kentoj
Feb 27 2018 23:29
@spencergibb how do I specify a CorsConfiguration for the CorsProcessor in Spring web? That is the root of why I am getting an "Invalid CORS" request. None of my requests from a JS client have the ORIGIN header so all are getting denied as "Invalid CORS request"
I think I see how to do it. Just a sec
Kent Johnson
@kentoj
Feb 27 2018 23:37

I used a CorsConfigurationSource bean and things still aren't working:

 @Bean
    fun corsConfigurationSource(): CorsConfigurationSource {
        val configuration = CorsConfiguration()
        configuration.allowedOrigins = Arrays.asList("*")
        configuration.allowedMethods = Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD")
        configuration.allowedHeaders = Arrays.asList("Authorization", "Origin", "X-Requested-With", "Content-Type", "Content-Length", "Accept")
        configuration.exposedHeaders = Arrays.asList("Authorization", "Origin", "X-Requested-With", "Content-Type", "Content-Length", "Accept")
        configuration.allowCredentials = true
        configuration.maxAge = 3600L
        val source = UrlBasedCorsConfigurationSource(PathPatternParser())
        source.registerCorsConfiguration("/**", configuration)
        return source
    }

What should I try next? I am just debugging now.