Log health check exceptions.
We now rely on the exception handling of AbstractHealthIndicator and AbstractReactiveHealthIndicator by removing our own exception handling code. Closes gh-242.
This commit is contained in:
@@ -35,38 +35,30 @@ public class VaultHealthIndicator extends AbstractHealthIndicator {
|
||||
this.vaultOperations = vaultOperations;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Builder builder) {
|
||||
|
||||
try {
|
||||
VaultHealth vaultHealthResponse = vaultOperations.opsForSys().health();
|
||||
|
||||
VaultHealth vaultHealthResponse = vaultOperations.opsForSys().health();
|
||||
|
||||
if (!vaultHealthResponse.isInitialized()) {
|
||||
builder.down().withDetail("state", "Vault uninitialized");
|
||||
}
|
||||
else
|
||||
|
||||
if (vaultHealthResponse.isSealed()) {
|
||||
builder.down().withDetail("state", "Vault sealed");
|
||||
}
|
||||
else
|
||||
|
||||
if (vaultHealthResponse.isStandby()) {
|
||||
builder.up().withDetail("state", "Vault in standby");
|
||||
}
|
||||
else {
|
||||
builder.up();
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(vaultHealthResponse.getVersion())) {
|
||||
builder.withDetail("version",
|
||||
vaultHealthResponse.getVersion());
|
||||
}
|
||||
if (!vaultHealthResponse.isInitialized()) {
|
||||
builder.down().withDetail("state", "Vault uninitialized");
|
||||
}
|
||||
catch (Exception e) {
|
||||
builder.down(e);
|
||||
else
|
||||
|
||||
if (vaultHealthResponse.isSealed()) {
|
||||
builder.down().withDetail("state", "Vault sealed");
|
||||
}
|
||||
else
|
||||
|
||||
if (vaultHealthResponse.isStandby()) {
|
||||
builder.up().withDetail("state", "Vault in standby");
|
||||
}
|
||||
else {
|
||||
builder.up();
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(vaultHealthResponse.getVersion())) {
|
||||
builder.withDetail("version", vaultHealthResponse.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,21 +49,14 @@ public class VaultReactiveHealthIndicator extends AbstractReactiveHealthIndicato
|
||||
@Override
|
||||
protected Mono<Health> doHealthCheck(Builder builder) {
|
||||
|
||||
try {
|
||||
|
||||
return vaultOperations
|
||||
.doWithSession(it -> it.get().uri("sys/health").exchange())
|
||||
.flatMap(it -> it.bodyToMono(VaultHealthImpl.class))
|
||||
.onErrorResume(WebClientResponseException.class,
|
||||
VaultReactiveHealthIndicator::deserializeError)
|
||||
.map(vaultHealthResponse -> {
|
||||
return getHealth(builder, vaultHealthResponse);
|
||||
});
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
return Mono.just(builder.down(e).build());
|
||||
}
|
||||
return vaultOperations
|
||||
.doWithSession(it -> it.get().uri("sys/health").exchange())
|
||||
.flatMap(it -> it.bodyToMono(VaultHealthImpl.class))
|
||||
.onErrorResume(WebClientResponseException.class,
|
||||
VaultReactiveHealthIndicator::deserializeError)
|
||||
.map(vaultHealthResponse -> {
|
||||
return getHealth(builder, vaultHealthResponse);
|
||||
});
|
||||
}
|
||||
|
||||
private static Mono<? extends VaultHealthImpl> deserializeError(
|
||||
|
||||
Reference in New Issue
Block a user