spring-cloud / spring-cloud/spring-cloud-netflix

Unable to configure Eureka port

Open
#3,889 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
5k
Forks
2.5k
Avg merge
1d 2h
Merged PRs (30d)
10

Description

We need to be able to run our services with dynamic ports in Amazon ECS. We have an internal Spring Boot starter which is able to successfully get the ECS port and set it on a new EurekaInstanceConfigBean bean.

However, the EurekaAutoServiceRegistration class is overriding this value.

Here are our log files. You can see that our starter is finding port 32768. However, you can also see where EurekaAutoServiceRegistration sets it afterward.

2020-09-09 16:18:58.021  INFO [,] 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8001 (http)
2020-09-09 16:18:58.987 DEBUG [,] 1 --- [           main] c.a.s.cloud.boot.EurekaAutoConfigure     : Received host port 32768 from ECS container metadata.
2020-09-09 16:18:58.988  INFO [,] 1 --- [           main] c.a.s.cloud.boot.EurekaAutoConfigure     : Setting non-secure port to 32768
2020-09-09 16:19:02.370  INFO [,] 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8001 (http) with context path ''
2020-09-09 16:19:02.375  INFO [,] 1 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8001 

I believe the relevant code in Spring Cloud Eureka is this:
https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaAutoServiceRegistration.java#L139-L150

It seems that this registration should not be attempting to override an existing configuration. Also, since it running based on a, WebServerInitializedEvent, we can't use Spring Boot's configure-after controls.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with EurekaAutoServiceRegistration.java at the linked lines and trace how WebServerInitializedEvent leads to the port update. Reproduce the interaction with the custom EurekaInstanceConfigBean and verify that an existing configured port is not overwritten after the web server starts.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.