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

11th
Feb 2016
Stevo Slavić
@sslavic
Feb 11 2016 08:44
hello everyone
I'm trying to override zuul route path using environment variable
configprops show override for existing path actually happens, but additionally a new route is added with same path
Stevo Slavić
@sslavic
Feb 11 2016 08:54
and configprops does not include configured ribbon list of servers for services
I'm using M5
Dave Syer
@dsyer
Feb 11 2016 08:56
Hard to really know what you did without more details
Stevo Slavić
@sslavic
Feb 11 2016 08:57
have few routes defined, assigned them service id, and for each service defined ribbon list of server
now would like to override through environment variable just path of one of the routes
in CF, cf set-end app ZUUL_ROUTES_SOMEROUTE_PATH /new/path
before setting env var, configprops doesn't show configured ribbon list of servers for services
after setting env var, configprops shows that path property for SOMEROUTE has been overriden, but it also shows a new route definition, route is named SOMEROUTE_PATH
Dave Syer
@dsyer
Feb 11 2016 09:06
I guess using UPPER_CASE is bad for this use case
You are trying to bind to a Map<String,ZuulRoute> and Spring Boot doesn't know if "SOMEROUTE_YOURPATH" is a key or an entry.
You could use SPRING_APPLICATION_JSON to be more precise about the properties you want to set
Stevo Slavić
@sslavic
Feb 11 2016 09:09
googled spring-projects/spring-boot@1f675c0
Mark Ferguson
@fergoid
Feb 11 2016 09:09
Hi @dsyer I've been looking at your blog about binding to data services with Spring Boot in CF. I really like the idea of injecting the 'cloud.services.* environment variables into my data sources through SB and have tried it out. It works for me up to a point except I never get the jdbcurl variable created. Digging a bit further it seems our problem might be that we create our database services (which are almost all exclusively Oracle) as user provided services and these don't support tags to provide the hints you talk about in the blog. I can get to username, password and uri variables. Do you see any issues with creating VCAP variables directly, would that solve the problem if we provided an "oracle" tag?
Dave Syer
@dsyer
Feb 11 2016 09:15
User Provided services don't usually contain the right metadata for the buildpack to detect them as JDBC services
You certainly can't create any VCAP_* variables with cf set-env if that's what you mean
Those are reserved for the platform
I believe there is a URL signature that works as well as the "tag" metadata though
Mark Ferguson
@fergoid
Feb 11 2016 09:20
We use 'oracle://username:password@host:port/SID' for our Oracle user provided services.
that should read ':' + 'p' not en emoji!
Dave Syer
@dsyer
Feb 11 2016 09:22
Yeah the URL prefix is what is important
@fergoid you can use Markdown to escape code (backticks)
Mark Ferguson
@fergoid
Feb 11 2016 09:43
@dsyer thanks!
Stevo Slavić
@sslavic
Feb 11 2016 11:09
couldn't get SPRING_APPLICATION_JSON to work for me yet, what's configured in there doesn't override settings in app
thinking maybe there's issue with quotes in env var

used
cf set-env app SPRING_APPLICATION_JSON '{"zuul": { "routes": { "foo": { "path": "/foo", "stripPrefix": false, "retryable": false, "serviceId": "foo_service" }}}}'

and "cf env app" lists:
SPRING_APPLICATION_JSON: {"zuul": { "routes": { "foo": { "path": "/foo", "stripPrefix": false, "retryable": false, "serviceId": "foo_service" }}}}

but configprops after cf restage shows route definition unaffected by env var

Dave Syer
@dsyer
Feb 11 2016 11:21
Yes, you will need to escape it properly.
Stevo Slavić
@sslavic
Feb 11 2016 11:22
clear, thanks
Dave Syer
@dsyer
Feb 11 2016 11:22
but that looks like valid JSON
Is it showing up in the /env endpoint?
Stevo Slavić
@sslavic
Feb 11 2016 11:23
yes it is, in systemEnvironment
"SPRING_APPLICATION_JSON": "{\"zuul\": { \"routes\": { \"foo\": { \"path\": \"/foo\", \"stripPrefix\": false, \"retryable\": false, \"serviceId\": \"foo_service\" }}}}"
Dave Syer
@dsyer
Feb 11 2016 11:25
But it should be in its own property source as well
You are using an old version of Spring Boot?
Stevo Slavić
@sslavic
Feb 11 2016 11:26
should be 1.3.2.RELEASE, let me check
Dave Syer
@dsyer
Feb 11 2016 11:27
With 1.3.2 you should see a property source called "spring.application.json"
Stevo Slavić
@sslavic
Feb 11 2016 11:27
cf files app app/lib lists 1.3.2 only
Dave Syer
@dsyer
Feb 11 2016 11:27
or a WARN log telling you that it couldn't parse it
Stevo Slavić
@sslavic
Feb 11 2016 11:27
will check both
Stevo Slavić
@sslavic
Feb 11 2016 11:52
no warning, there is spring.application.json entry in env output
Dave Syer
@dsyer
Feb 11 2016 11:53
Is your app running in PWS?
Stevo Slavić
@sslavic
Feb 11 2016 11:53
no, private CF installation
Dave Syer
@dsyer
Feb 11 2016 11:54
Not on the internet?
Stevo Slavić
@sslavic
Feb 11 2016 11:54
"spring.application.json": {
"zuul.routes.foo.path": "/foo",
"zuul.routes.foo.stripPrefix": false,
"zuul.routes.foo.retryable": false,
"zuul.routes.foo.serviceId": "foo_service"
},
Dave Syer
@dsyer
Feb 11 2016 11:54
Can you push it to PWS?
Where are the routes defined?
Probably in a property source that you can't override?
Like in config server?
Stevo Slavić
@sslavic
Feb 11 2016 11:55
no, sorry, not an option
routes are defined in application.yml in app jar
Dave Syer
@dsyer
Feb 11 2016 11:56
I need to see more of the /env
Stevo Slavić
@sslavic
Feb 11 2016 11:56
services are in env specific application.yml
Dave Syer
@dsyer
Feb 11 2016 11:56
and the /routes
Stevo Slavić
@sslavic
Feb 11 2016 11:58
routes are uneffected by env var
{
"/bar": "foo_service",
...
}
would like to change /bar to /foo
with env var
Dave Syer
@dsyer
Feb 11 2016 11:58
I know
But I can't see all the data
Matt Benson
@mbenson
Feb 11 2016 21:59
@spencergibb or anyone concerned: note that Spring-cloud Feign support seems to suffer from the same problem as Spring MVC: https://jira.spring.io/browse/SPR-11055, again conflicting with what is advertised in spring-cloud Feign docs
Dave Syer
@dsyer
Feb 11 2016 22:02
We can fix the docs. What is it that is inconsistent exactly?
Matt Benson
@mbenson
Feb 11 2016 22:03
same thing you and I worked on, @dsyer ... the docs say that you can define your REST contract in a single Java interface and reuse it for your server and client alike. But the fact that parameter annotations are not inherited automatically breaks that.
Dave Syer
@dsyer
Feb 11 2016 22:04
OK, consider it fixed.
Matt Benson
@mbenson
Feb 11 2016 22:05
Based on your suggestions I got this working on the server end with a custom HandlerMethodArgumentResolver implementation. Next I'll be attempting to customize the SpringMvcContract on the Feign side.
because I'm really fond of the idea of this; I just note that it doesn't work out of the box
Dave Syer
@dsyer
Feb 11 2016 22:06
Well, you know I'm sure that the fix will come from the JIRA link you posted above, if it comes from anywhere
You could have helped your case there by not muddying the waters with client-side concerns, which really have nothing to do with the issue.
Matt Benson
@mbenson
Feb 11 2016 22:08
my only actual contribution to that issue has been to note that the problem affects parent classes as well as interfaces.
wrt the fix coming from there, I'm not so sure... even if they fix it in Spring webmvc it looks like the Feign handling of this is specific to spring-cloud-netflix-core
at some point I had posted my final solution to the server side issue in either this room or spring-boot, because I was pretty happy with it. It's working fine here.
Dave Syer
@dsyer
Feb 11 2016 22:11
spring-cloud/spring-cloud-netflix@2323512
If you have something that fixes the issue please send a PR
I thought the annotation processing was shared (implemented in Spring Web)
Matt Benson
@mbenson
Feb 11 2016 22:12
modulo the spelling problem there, okay
Dave Syer
@dsyer
Feb 11 2016 22:12
spelling?
"gernarally"
Matt Benson
@mbenson
Feb 11 2016 22:12
s/gernarally/generally/
personally I am having a hard time feeling a shared interface as representing "tight coupling" though ;)
but I guess that's a matter of opinion
Dave Syer
@dsyer
Feb 11 2016 22:15
I guess
ANyway, if we can fix something in Spring Cloud, please suggest a patch.
Like I said, I thought it was a Spring Web thing.
It might be more on the Feign side with Cloud I guess
Matt Benson
@mbenson
Feb 11 2016 22:16
well, I can certainly patch the offending classes in a similar manner. What's that, Java 7?
Dave Syer
@dsyer
Feb 11 2016 22:16
Also consider sending patches there
Java 7 is the minimum for Spring Cloud at the moment. What do you mean?
Matt Benson
@mbenson
Feb 11 2016 22:17
that's what I meant, yes. I think I'm using some lambdas and such in my webmvc solution
oh yeah, and a nice helper method from Apache Commons Lang, but I'll use Spring facilities only :P
Dave Syer
@dsyer
Feb 11 2016 22:20
Don't we need to fix this in Feign?
The Annotation instances come from there via Method.getAnnotations()
If the annotations are defined on the parent interface it won't know how to find them
Maybe you have a different use case in mind
Matt Benson
@mbenson
Feb 11 2016 22:22
I was thinking to make the various org.springframework.cloud.netflix.feign.AnnotatedParameterProcessor implementations aware of method parameter inheritance, but you may be right... the annotations are passed into those. I hadn't fully analyzed it yet.
Dave Syer
@dsyer
Feb 11 2016 22:22
I think you have one interface (used in the client and server)
only the server suffers from the inheritance problem in your use case
Matt Benson
@mbenson
Feb 11 2016 22:25
oh, I see what the problem is... the code is finding the @PathVariable but it doesn't like the fact that I was using parameter name discovery. It wants an explicitly specified variable name
Dave Syer
@dsyer
Feb 11 2016 22:30
That sounds like a good one to fix
But again, it might be a Feign issue.
Spring is usually pretty good at using parameter names where it can.
Other libraries have to implement that stuff themselves
Matt Benson
@mbenson
Feb 11 2016 22:32
I think it can be solved in spring-cloud, but the necessary foundation may not be there, and that would be from Feign
Dave Syer
@dsyer
Feb 11 2016 22:33
That's what I said I think
Matt Benson
@mbenson
Feb 11 2016 22:33
well, it's not that the parameter name necessarily needs to be gotten from Feign, but I'm still trying to determine whether Feign provides enough information to get to the method owning the annotated parameter
Dave Syer
@dsyer
Feb 11 2016 22:36
It doesn't
Matt Benson
@mbenson
Feb 11 2016 22:36
still, the SpringMVCContract seems to touch the methods a lot
Dave Syer
@dsyer
Feb 11 2016 22:37
Give it a shot then
Matt Benson
@mbenson
Feb 11 2016 22:37
I'll try
pradeepkusingh
@pradeepkusingh
Feb 11 2016 23:12
@dsyer : do we haev any update on brixton release ?