I am having Eureka server, Spring cloud config server and Zuul in my environment. The Eureka server is protected with token based mechanism and expects a valid token to register/get applications etc..
I am using Spring boot 1.5.4 and spring cloud dependencies as Dalston.SR2. ie., I have spring-boot-starter 1.5.4.RELEASE, spring-cloud-starter-eureka 1.3.2.RELEASE, spring-cloud-starter-zuul 1.3.2.RELEASE, spring-cloud-starter-config 1.3.2.RELEASE.
I have defined DiscoveryClientOptionalArgs bean and injected ClientFilter instance into it at EurekaClient. The ClientFilter takes care of adding the token in Authorization header.
I am trying to load the zuul configuration from Spring cloud config server using Discovery first approach but the ClientFilter is not working as expected. i.e., the application is trying to connect to eureka and looking for the config server id before the DiscoveryClientOptionalArgs bean get created.
When I launched the zuul service, following is happened.
- The DiscoveryClient object tried to get instance registry info from the eureka server (which is protected), got 403.
- DiscoveryClientConfigServiceBootstrapConfiguration refresh method called ConfigServerInstanceProvider.getConfigServerInstance() which returned "No instances found of configserver (CONFIGSERVER)".
- The application tried to fetch config from default path (http://localhost:8888) and not able to locate PropertySource (since config server is running in different port).
- Then application context loaded, all filters registered.
- DiscoveryClient shutdown happened, Unregistered and Completed shut down of DiscoveryClient
- Again, DiscoveryClient object initialized and tried to get instance registry info from the eureka server (which is protected), this time got valid response since the custom ClientFilter kicked in during the execution and added Authorization header.
- Registered the zuul instance in eureka.
- Again, DiscoveryClientConfigServiceBootstrapConfiguration refresh method called ConfigServerInstanceProvider.getConfigServerInstance() which returned "No instances found of configserver (CONFIGSERVER)".
In debug mode, I found that the ConfigServerInstanceProvider holds the old version of DiscoveryClient (created before step 4 which doesn't have any eureka instances information) but the DiscoveryClient created after step 4 has the eureka instances information (eurekaserver, CONFIGSERVER, zuulserver).
Any thoughts on why ConfigServerInstanceProvider doesn't have the DiscoveryClient object reference created after step 4 ? or Am I missing any configurations?
Comment From: DustyDuprel
Did you figure this out?
Comment From: spencergibb
Is this still an issue?
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: deepigarg
I was able to work around this issue by adding the @Configuration
file containing the DiscoveryClientOptionalArgs bean as a bootstrap configuration as follows:
In the resources/META-INF
folder, create a file called spring.factories
and specify the custom configuration:
org.springframework.cloud.bootstrap.BootstrapConfiguration = com.my.discovery.client.CustomDiscoveryClientConfiguration