Open dlvenable opened 4 years ago
yeah, if the port is set by properties and it is greater than zero we should use that.
Thank you for the response. For additional information, here is a snippet from where we do our configuration.
You can see that our log line "Setting non-secure port to {}" is being reached in the logs above.
@Value("${server.port:#{null}}")
private Integer port;
@Bean
@Profile("production")
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils)
{
EurekaInstanceConfigBean eurekaConfig = new EurekaInstanceConfigBean(inetUtils);
AmazonInfo awsInfo = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
eurekaConfig.setDataCenterInfo(awsInfo);
eurekaConfig.setIpAddress(awsInfo.get(AmazonInfo.MetaDataKey.localIpv4));
eurekaConfig.setHostname(awsInfo.get(AmazonInfo.MetaDataKey.localHostname));
Integer port = getInstancePort(); // This is just a method to get the port from AWS ECS
if(port != null)
{
log.info("Setting non-secure port to {}", port);
eurekaConfig.setNonSecurePort(port);
}
return eurekaConfig;
}
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.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.