Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Support for Sentinels #64

Closed
vipinvkmenon opened this issue Sep 26, 2017 · 4 comments
Closed

No Support for Sentinels #64

vipinvkmenon opened this issue Sep 26, 2017 · 4 comments
Assignees

Comments

@vipinvkmenon
Copy link

When I deploy a Spring Application on CF. the java buildpack tries to reconfigure spring to work with its 'cloud' profile.

https://github.com/cloudfoundry/java-buildpack-auto-reconfiguration

As a result, the application picks up this configuration/profile.Due to this, the application fails when a Redis Multinode/HA instance is used.

I feel this is something to do with the way the HA/ Multinode Redis Service is deployed/ provided.

Our fix for the timebeing was to disable autoconfiguration through the manifest file.

JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'

Does Spring cloud not support Sentinels. Or is this due to some other issue?

@scottfrederick
Copy link
Contributor

@vipinvkmenon Can you give an example of the messages or exceptions given when the application fails to start? An example of the VCAP_SERVICES environment variable created for the failing app would be helpful also.

This is likely caused by the fact that Spring Cloud Connectors (which Java buildpack's auto-reconfiguration uses) does not currently support Redis sentinels. See spring-cloud/spring-cloud-connectors#185.

@nebhale
Copy link
Contributor

nebhale commented Oct 3, 2017

I’d agree that this is the root cause.

@markbigler
Copy link

@vipinvkmenon For a "simple" connection to your HA redis service, the following configuration should do the job:

@EnableConfigurationProperties(RedisConnectionCloudProperties.class)
public static class RedisConnectionCloudConfiguration extends AbstractCloudConfig {
	@Bean
	public RedisConnectionFactory redisConnectionFactory(RedisConnectionCloudProperties properties) {
		RedisConnectionFactory connectionFactory = connectionFactory().redisConnectionFactory(properties.getServiceId());
		if(connectionFactory instanceof JedisConnectionFactory) {
			JedisPoolConfig poolConfig = new JedisPoolConfig();
			if(properties.getConnections() != null) {
				poolConfig.setMaxTotal(properties.getConnections());
				poolConfig.setMaxIdle(properties.getConnections());
			}
			poolConfig.setTestOnBorrow(true); // validate and drop closed connections

			((JedisConnectionFactory)connectionFactory).setPoolConfig(poolConfig);
		}
		return connectionFactory;
	}
}

@Validated @ConfigurationProperties(prefix = "yourapp.redis")
public static class RedisConnectionCloudProperties {
	@NotNull private String serviceId;
	private Integer connections;
	public String getServiceId() { return serviceId; }
	public void setServiceId(String serviceId) { this.serviceId = serviceId; }
	public Integer getConnections() { return connections; }
	public void setConnections(Integer connections) { this.connections = connections; }
}

Nevertheless, it would be very helpful if you could add an example of your VCAP_SERVICES environment variable to spring-cloud/spring-cloud-connectors#185.

@nebhale nebhale self-assigned this Nov 2, 2017
@nebhale
Copy link
Contributor

nebhale commented Nov 2, 2017

Since there’s been no response on this issue from the original in a couple of weeks, I’m going to close it. If you’d like to see it re-opened, please comment on the issue and I’ll reopen it.

@nebhale nebhale closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants