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

[BUG]: fixed health check return always false for credential services #315

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;

import static dev.sunbirdrc.registry.middleware.util.Constants.CONNECTION_FAILURE;

Expand Down Expand Up @@ -214,7 +215,8 @@ public String getServiceName() {
public ComponentHealthInfo getHealthInfo() {
try {
ResponseEntity<String> response = retryRestTemplate.getForEntity(healthCheckUrl);
if (!StringUtils.isEmpty(response.getBody()) && JSONUtil.convertStringJsonNode(response.getBody()).get("status").asText().equalsIgnoreCase("UP")) {
JsonNode responseBody = JSONUtil.convertStringJsonNode(response.getBody());
if (!StringUtils.isEmpty(response.getBody()) && Stream.of("OK","UP").anyMatch(d -> d.equalsIgnoreCase(responseBody.get("status").asText()))) {
logger.debug("{} service running!", this.getServiceName());
return new ComponentHealthInfo(getServiceName(), true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.IOException;
import java.util.*;
import java.util.stream.Stream;

import static dev.sunbirdrc.registry.middleware.util.Constants.*;

Expand Down Expand Up @@ -140,7 +141,8 @@ public String getServiceName() {
public ComponentHealthInfo getHealthInfo() {
try {
ResponseEntity<String> response = retryRestTemplate.getForEntity(healthCheckUrl);
if (!StringUtils.isEmpty(response.getBody()) && JSONUtil.convertStringJsonNode(response.getBody()).get("status").asText().equalsIgnoreCase("UP")) {
JsonNode responseBody = JSONUtil.convertStringJsonNode(response.getBody());
if (!StringUtils.isEmpty(response.getBody()) && Stream.of("OK", "UP").anyMatch(d -> d.equalsIgnoreCase(responseBody.get("status").asText()))) {
logger.debug("{} service running!", this.getServiceName());
return new ComponentHealthInfo(getServiceName(), true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;

import static dev.sunbirdrc.registry.Constants.HTTPS_URI_PREFIX;
import static dev.sunbirdrc.registry.Constants.HTTP_URI_PREFIX;
Expand Down Expand Up @@ -230,7 +231,8 @@ public String getServiceName() {
public ComponentHealthInfo getHealthInfo() {
try {
ResponseEntity<String> response = retryRestTemplate.getForEntity(healthCheckUrl);
if (!StringUtils.isEmpty(response.getBody()) && JSONUtil.convertStringJsonNode(response.getBody()).get("status").asText().equalsIgnoreCase("UP")) {
JsonNode responseBody = JSONUtil.convertStringJsonNode(response.getBody());
if (!StringUtils.isEmpty(response.getBody()) && Stream.of("OK", "UP").anyMatch(d -> d.equalsIgnoreCase(responseBody.get("status").asText()))) {
logger.debug("{} service running!", this.getServiceName());
return new ComponentHealthInfo(getServiceName(), true);
} else {
Expand Down
Loading