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

11th
Dec 2015
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 14:41
I'm trying to use the feign inheritance like this http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance but my exceptions thrown are not properly handled by the @ControllerAdvice I have, I think it's because the Resource implementing the interface becomes a JDK Proxy. Any ways around this? It works by adding a @ExceptionHandler to the interface but I'd like to reuse my @ControllerAdvice.
I'm using Angel.SR4 though, not sure if it changes anything.
btw I had to add @RestController to the interface as well as the resource, otherwise the resource would try to find a corresponding view with the object returned and ended up on a 404.
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 15:11
using spring.aop.proxy-target-class: true solves the problem but I'm unsure if it's a good idea to use that. Thoughts?
Dave Syer
@dsyer
Dec 11 2015 15:37
I imagine if you use interfaces for everything you don't need to do that
It's not really a bad idea though
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 16:15
alright I'll keep that then, thanks!
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:26
does anyone have any advice as far as how to configure eureka clients to get the correct url for the eureka server when running inside of Docker containers using Docker Compose?
i have one solution
but it is a little fragile
basically I link the clients to the server in the docker compose yaml file
and then do some variable substitution in the application.yml files of the clients to get the ip of the linked eureka server
---
spring:
  profiles: docker
eureka:
  client:
    serviceUrl:
      defaultZone: http://${EUREKA_PORT_8761_TCP_ADDR}:8761/eureka/
John G
@jgolubenko
Dec 11 2015 21:28
I don't know if it's good idea to run Eureka inside of Docker... it's a central piece of the ecosystem. Dockerized apps usually means disposable things...
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:28
this works because my eureka server container is named eureka in my docker compose file and is linked to this client so docker compose creates an environment variable called EUREKA_PORT_8761_TCP_ADDR in the client container
the fragility comes in the naming though, so if the name of the eureka container changes in the docker compose file than the name of the environment variable changes as well and everything breaks :(
@jgolubenko fair point
although there are certainly people also looking at using Docker for long running applications like web apps
in addition you can use Docker to easily spin up the entire cloud native application
for testing or development purposes
John G
@jgolubenko
Dec 11 2015 21:32
We were thinking about it for quite some time and decided go have multiple Eureka (in peer-aware config) on it's own "hardware". It's just too many things bound to Eureka discovery and we felt docker it's not a place to run such thing. Just my 2c.
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:35
I am sure there are good reasons not do spin up eureka in a container in production, but I still thing there may be other good use cases to do it for development and testing purposes
John G
@jgolubenko
Dec 11 2015 21:36
@ryanjbaxter yeah I got what you are saying, certainly correct in that case.
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:37
anyways if anyone has any good solutions to the problem, I would be interrested in hearing them
i also face a similar problem regarding the hostname the clients use to register with eureka
John G
@jgolubenko
Dec 11 2015 21:38
I don't know if cloud config server can help you with what you are trying to do. E.g. clients would not store any application.yml configs, but rather talk to config server and it will provide them with configs at the bootstrap phase
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:38
the general issue here is there is a disconnect between the docker compose file and the application configuration
@jgolubenko that is an interresting approach, i had not though of that, mainly bc i am not using a config server in my app yet :)
John G
@jgolubenko
Dec 11 2015 21:40
Hostnames & docker also pain in the ... have you tried to register with ip's instead? Or hostnames is a must-have for you
e.g. eureka: instance: prefereIpAddress: true
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:41
i have not tried the using just the ip addresses. i went down the hostname path because of how linking works with docker containers
but I can see if using ipAddresses avoids the hostname problem
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 21:50
using ipAddress will register the private docker ip address, it won't get you far
we're running eureka inside docker and we used the EIP approach using DNS (we're using AWS)
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:51
true, but if it is only communication between the containers I am worring about at the moment i THINK it might work
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 21:51
and for the hostname problem, we query the AWS metadata URL to get the host ip address and that's the IP we're using to register in eureka. This limit you to one application per server though if you're using a static port
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:52
im hoping there is a more general solution that doesnt rely on the cloud provider :)
ccit-spence
@ccit-spence
Dec 11 2015 21:52
@jebeaudet That is exactly what I did with AWS ECS, the port thing is annoying because you have to now manage ports for all apps
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 21:52
yea, well Netflix is heavily binded on AWS technologies :P
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:53
but spring cloud is not :clap:
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 21:54
I meant Eureka here
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:54
i know what u are saying
ccit-spence
@ccit-spence
Dec 11 2015 21:54
@ryanjbaxter I do use Docker for Eureka in development. Seems to work fairly well. I make sure all of the dev profiles specify their host names for each app.
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:54
just giving u a hard time
@ccit-spence what do u mean by dev profiles? are u referring to spring profiles?
John G
@jgolubenko
Dec 11 2015 21:55
Let me check our config, because inside app docker registers with external IP in our eureka
ccit-spence
@ccit-spence
Dec 11 2015 21:55
yes
I launch Eureka instances with —net=host Still need different ports for each instance
On a Mac I end up with Eureka on 192.168.99.100
port 8761, 8762 etc
Might not be the best solution but works
John G
@jgolubenko
Dec 11 2015 21:57
hmm nothing special in our config. '''eureka:
instance:
preferIpAddress: true'''
how to post code blocks here
ccit-spence
@ccit-spence
Dec 11 2015 21:58
back tics not commas
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:58
same as markdown
ccit-spence
@ccit-spence
Dec 11 2015 21:58
`
John G
@jgolubenko
Dec 11 2015 21:58
  instance:
    preferIpAddress: true
Ryan Baxter
@ryanjbaxter
Dec 11 2015 21:58
@ccit-spence -net is only available when using docker run and not in docker compose from what i see in the docs
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 21:59
are you in an AWS environment @jgolubenko ?
ccit-spence
@ccit-spence
Dec 11 2015 21:59
@ryanjbaxter Yeah, you’re right. I use Docker run
And that is why I use Docker run
John G
@jgolubenko
Dec 11 2015 21:59
docker run -d -p 8080:8282 application is how we run it
ccit-spence
@ccit-spence
Dec 11 2015 22:00
@jgolubenko Are all of your instances within Docker
Ryan Baxter
@ryanjbaxter
Dec 11 2015 22:00
docker compose just makes it so much easier to spin up the entire application
John G
@jgolubenko
Dec 11 2015 22:00
Except Eureka
ccit-spence
@ccit-spence
Dec 11 2015 22:00
How are you getting the Host information?
docker compose is nice, couldn’t get it to work
Ryan Baxter
@ryanjbaxter
Dec 11 2015 22:02
How are you getting the Host information?
is that a question for me?
ccit-spence
@ccit-spence
Dec 11 2015 22:02
sorry for @jgolubenko
Ryan Baxter
@ryanjbaxter
Dec 11 2015 22:02
ok
i got to run guys thanks for the pointers i will try the preferIPAddress config and let u know how that goes for me
and my situation anyways
John G
@jgolubenko
Dec 11 2015 22:04
@ccit-spence good question. We had this env up for quite a while. I've looked at Dockerimage and current configs but I don't see a place where it 'remaps' internal->external. Hmm..
ccit-spence
@ccit-spence
Dec 11 2015 22:05
For AWS ECS this is what I did to get the Host information. It runs on task boot
#!/bin/sh
export HOST=$(curl --retry 5 --connect-timeout 3 -s 169.254.169.254/latest/meta-data/local-hostname)
export LOCAL_IP=$(curl --retry 5 --connect-timeout 3 -s 169.254.169.254/latest/meta-data/local-ipv4)
exec "$@
John G
@jgolubenko
Dec 11 2015 22:05
@ryanjbaxter You can always pass ENV MY_HOSTNAME in dockerimage and use that in eureka.instance.hostname=${MY_HOSTNAME:localhost} or something like that.
ccit-spence
@ccit-spence
Dec 11 2015 22:05
Then use the new var to populate the properties file in Spring
Jacques-Etienne Beaudet
@jebeaudet
Dec 11 2015 22:06
you could also use the AmazonInfo implementationDataCenterInfo in your EurekaInstanceConfigBean @ccit-spence it does all that automatically
that's what we do, works like a charm
ccit-spence
@ccit-spence
Dec 11 2015 22:07
@jebeaudet I chose that route to keep AWS code out of the project. Not sure why
Your solution is better
ccit-spence
@ccit-spence
Dec 11 2015 22:16
On another subject anyone using Vaadin with Spring Cloud?