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

19th
Dec 2018
Rahul Singh
@rahulsingh336
Dec 19 2018 04:58
Hello, I am facing issues with ConfigClientWatch

i found that ConfigClientWatch#watchConfigServer had some problem:

@Scheduled(initialDelayString = "${spring.cloud.config.watch.initialDelay:180000}", fixedDelayString = "${spring.cloud.config.watch.delay:500}")
public void watchConfigServer() {
if (this.running.get()) {
String newState = this.environment.getProperty("config.client.state");
String oldState = ConfigClientStateHolder.getState();
if (stateChanged(oldState, newState)) {
ConfigClientStateHolder.setState(newState);
this.refresher.refresh();
}
}
}

String newState = this.environment.getProperty("config.client.state");

As, I can see, in class ConfigServicePropertySourceLocator.java, key - "config.client.state" is put in CompositePropertySource.
I am not sure, if we ever would be able to get config.client.state from environment.

Could you please help?
Marcos Barbero
@marcosbarbero
Dec 19 2018 06:23
Hi @rahulsingh336 what's the actual issue?
In both classes you're getting the property from the Environment with something like this this.environment.getProperty("config.client.state");
Rahul Singh
@rahulsingh336
Dec 19 2018 08:49

@marcosbarbero yes right, but when I debugged the code, then in class ConfigServicePropertySourceLocator, we get null when we try to get the key from environement.
and it is put in CompositePropertySource as below:-

if (StringUtils.hasText(result.getState()) || StringUtils.hasText(result.getVersion())) {
HashMap<String, Object> map = new HashMap<>();
putValue(map, "config.client.state", result.getState());
putValue(map, "config.client.version", result.getVersion());
composite.addFirstPropertySource(new MapPropertySource("configClient", map));
}
return composite;

So, now when, ConfigClientWatch's , watchConfigServer() method runs, then it tries to find "config.client.state" in environment, which is always null, instead it should try to get it from CompositePropertySource.

Gilles Robert
@ask4gilles
Dec 19 2018 08:55
Hi,
Related to Spring cloud config server, I'm debating with a colleague regarding ENV variables. IMO, env variables should be defined on each client application server and SCC just provides the requested configuration containing ${ENV_VARIABLE} which is resolved at the client side. He is arguing that we should define all ENV variables on the config server. For me, these concerns are client related and have nothing to do with the SCC and we should be able to run any app without config server just by passing the config file containing env variables. Any thoughts on this? thanks!
Marcos Barbero
@marcosbarbero
Dec 19 2018 09:07
@rahulsingh336 please try to use markdown to format the code you post here, that makes it a lot more readable :)
Marcos Barbero
@marcosbarbero
Dec 19 2018 09:14
Hi @ask4gilles, what are those ENV_VARS? Is it related to the application itself or something else?
Either way, that would be great if each application could have at least a minimal setup to not make it so dependent on Config Server, if you move everything to the Config Server you probably gonna end up with a SPOF.
I would add to the Config Server only application related stuff in which differs from each environment but still have it as runnable as possible with a minimal configuration, also would be great if you could get a fallback to the Config Server in case it isn't available during the deployment time you don't stop the CD process.
Gilles Robert
@ask4gilles
Dec 19 2018 09:43
Hi @marcosbarbero ,
These ENV_VARIABLES are thing like postgres server address, rabbitMq address, credentials which vary by environment and by applications
Marcos Barbero
@marcosbarbero
Dec 19 2018 09:47
In this case I rather store it all in the Config Server than adding it as ENV_VAR.
Only one remark for the credentials, you have some options to not store it as plain text, you can encrypt it and store directly to the git repo or integrate it with HashiCorp Vault, and of course you can always leave this particular property as ENV_VAR
Gilles Robert
@ask4gilles
Dec 19 2018 09:50
ok thanks, related to credentials, indeed encrypted in a first phase, use Vault in a second phase
Ingo Griebsch
@ingogriebsch
Dec 19 2018 12:59

Hi all, we are just using Spring Boot 1.5.10 and Spring Cloud Edgware.SR5 and would like to implement a Feign client which is able to send multiple @RequestPart's.
The method declaration currently looks like this:

@RequestMapping(path = "/files", method = POST, consumes = MULTIPART_FORM_DATA_VALUE)
void insert(@RequestPart("file") MultipartFile file, @RequestPart("data") FileData data);

During startup we get the following exception: java.lang.IllegalStateException: Method has too many Body parameters
So it looks like the Feign contract prohibits to define more then one annotation which is not a 'http annotation' on such a method declaration.

Therefore we would like to ask if we are doing something wrong and if there is a possibility to get this case working. :)

choubani amir
@amirensit
Dec 19 2018 13:33
hello.
Any idea what is the difference between using Ribbon and LoadBalancerClient class ?
It is clear that both are client side load balancers.
Marcos Barbero
@marcosbarbero
Dec 19 2018 14:18
@amirensit LoadBalancerClient is an interface in which needs an implementations and there's this RibbonLoadBalancerClient implementation that uses Ribbon to do the client side load balance
choubani amir
@amirensit
Dec 19 2018 16:57
@marcosbarbero ok thanks
Spencer Gibb
@spencergibb
Dec 19 2018 18:22
@rahulsingh336 the state is specifically for vault backed config server. I don't believe it works with a composite
@ingogriebsch feign only accepts a single parameter as the body to a request