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

1st
Feb 2018
Haruhiko Nishi
@hanishi
Feb 01 2018 01:16

Hi regarding the question that I refereed, we have further investigated and found that there were port collision lead by some misconfiguration caused that issue. Our finding in the application log suggests that when app is deployed to a yarn container, tomcat is first started with its port set to 0 and then shortly after it looks like it is started again with its port 40110. When the app is launched and while the port setting is 0, it apparently registers with Eureka with the initial port in
${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}} and the entry in the registry remains as <hostname>.<application>:0 even if the port settings is changed in during the startup process as depicted below. I am aware eureka.instance.instanceId can be changed manually and doing so will solve this problem, but this is preferably set its default value .

  1. Why does Tomcat start with port 0
  2. Why does the Tomcat changes its port?
  3. Why does the Eureka registry is not updated with new eureka.instance.instanceId that has its new port in the identifier?
[root@testhost2 container_e63_1516947632538_0067_01_000003]# cat Container.stdout |grep Tomcat
2018-01-31 18:32:06.944  INFO 3313 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 0 (http)
2018-01-31 18:32:06.960  INFO 3313 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-01-31 18:32:06.981  INFO 3313 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2018-01-31 18:32:07.323  INFO 3313 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-31 18:32:30.034  INFO 3313 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 40110 (http)

Hi, I don't know if it is a bug or it is by design but I see unexpected Tomcat initialized with port(s): 0 (http) entries in the start up log files from all of the instances that are deployed to yarn cluster with having the deployment property set as deployer.<appname>.count=10

2018-01-29 17:32:02.618  INFO 24043 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 0 (http)
2018-01-29 17:32:02.631  INFO 24043 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-01-29 17:32:02.632  INFO 24043 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2018-01-29 17:32:02.882  INFO 24043 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-29 17:32:02.882  INFO 24043 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 6107 ms

All of the instance launched in a Yarn cluster will be therefore identified as hostname.domain:0 when registering themselves to Eureka server. This causes registry record to be overwritten.
Why does Tomcat get initialized with port 0? Is there any workaround to address this issue so each one of them will launch its embedded tomcat with none 0 port?

Spencer Gibb
@spencergibb
Feb 01 2018 01:19
@hanishi you'll need to change the instanceId then
Haruhiko Nishi
@hanishi
Feb 01 2018 01:21
@spencergibb Is this an expected behavior?
Spencer Gibb
@spencergibb
Feb 01 2018 01:22
@hanishi what is server.port being set to?
Haruhiko Nishi
@hanishi
Feb 01 2018 01:23
@spencergibb nothing
Spencer Gibb
@spencergibb
Feb 01 2018 01:23
where is 40110 coming from then, the default is 8080?
it looks like you're setting the port to 0 which says to use a random port
Haruhiko Nishi
@hanishi
Feb 01 2018 01:24
I don't know but its probably SCDF deployer?
Spencer Gibb
@spencergibb
Feb 01 2018 01:24
I don't know
You'll need to change eureka.instance.instanceId to something else
Haruhiko Nishi
@hanishi
Feb 01 2018 01:29
@spencergibb Thank you. I needed some professional insights
Spencer Gibb
@spencergibb
Feb 01 2018 01:29
NP
Viktor Gal
@vigsterkr
Feb 01 2018 18:59
hi! i have a quick question regarding property injection and inheritance: say i have an abstract class A that two properties x and y defined that are protected and i inherit a class B from this class A. now what i would like to have is that all the properties of B are actually injected from a property file. where in the property file i would have b.x = "foo" and b.y = "bar". but i would like to inject a different property for class C that is as well inherited from class A and in the property file i have c.x = "asdf" and c.y = "fdsa". i've tried too google around, but so far couldn't find a solution for it