From 1e4a44a265dcb76e495a416860417dcce30cafdb Mon Sep 17 00:00:00 2001 From: Chinmoy Chakraborty Date: Fri, 14 Apr 2023 12:47:52 +0530 Subject: [PATCH 1/5] Changed health endpoint response schema --- .../com/uci/dao/service/HealthService.java | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/uci/dao/service/HealthService.java b/src/main/java/com/uci/dao/service/HealthService.java index 6ee69ef..e17a686 100644 --- a/src/main/java/com/uci/dao/service/HealthService.java +++ b/src/main/java/com/uci/dao/service/HealthService.java @@ -4,12 +4,14 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.uci.dao.repository.XMessageRepository; import com.uci.utils.UtilHealthService; import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.health.Status; import org.springframework.stereotype.Service; @Service @@ -17,13 +19,27 @@ public class HealthService extends UtilHealthService { @Autowired private XMessageRepository xMessageRepository; + @Autowired + ObjectMapper mapper; + /** * Returns health node * * @return Mono */ public Mono getCassandraHealthNode() { - return getIsCassandraHealthy().map(healthy -> new ObjectMapper().createObjectNode().put("healthy", healthy)); + return Mono.fromCallable(() -> { + ObjectNode result = mapper.createObjectNode(); + try { + xMessageRepository.existsByUserId("Test"); + result.put("status", Status.UP.getCode()); + return result; + } catch(Exception e) { + result.put("status", Status.DOWN.getCode()); + result.put("message", e.getMessage()); + return result; + } + }); } /** @@ -36,37 +52,18 @@ public Mono getCassandraHealthNode() { public Mono getAllHealthNode() { ObjectNode resultNode = new ObjectMapper().createObjectNode(); Mono externalComponentHealth = super.getAllHealthNode(); - Mono cassandraHealth = getCassandraHealthNode().map(result -> { - ObjectNode objectNode = new ObjectMapper().createObjectNode(); - objectNode.put("name", "cassandra"); - objectNode.set("healthy", result.get("healthy")); - return objectNode; - }); - return Mono.zip(externalComponentHealth, cassandraHealth).map(healths -> { - resultNode.putArray("checks") - .add(healths.getT1().get("checks")) - .add(healths.getT2()); - resultNode.put("healthy", - healths.getT1().get("healthy").booleanValue() && - healths.getT2().get("healthy").booleanValue() + Mono cassandraHealth = getCassandraHealthNode(); + return Mono.zip(externalComponentHealth, cassandraHealth).map(results -> { + ObjectNode detailsNode = mapper.createObjectNode(); + detailsNode.set("cassandra", results.getT2()); + results.getT1().get("details").fields().forEachRemaining(detail -> detailsNode.set(detail.getKey(), detail.getValue())); + resultNode.set("details", detailsNode); + resultNode.put("status", + results.getT1().get("status").textValue().equals(Status.UP.getCode()) && + results.getT2().get("status").textValue().equals(Status.UP.getCode()) + ? Status.UP.getCode() : Status.DOWN.getCode() ); return resultNode; }); } - - /** - * Check if Cassandra connecting or not - * - * @return Mono - */ - private Mono getIsCassandraHealthy() { - return Mono.fromCallable(() -> { - try { - xMessageRepository.existsByUserId("Test"); - return true; - } catch(Exception e) { - return false; - } - }); - } } From 8c9071053ca715a2bcd5698086c5ac9e47ae1c20 Mon Sep 17 00:00:00 2001 From: pankajjangid05 Date: Thu, 27 Apr 2023 15:20:22 +0530 Subject: [PATCH 2/5] Creating new package for development and master branch --- .github/workflows/build-deploy.yml | 6 +++--- .github/workflows/build.yml | 4 ++-- pom.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index df6667c..c160b60 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -5,10 +5,10 @@ on: tags: - 'v*.*.*' branches: - ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"] pull_request: branches: - ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"] jobs: @@ -59,7 +59,7 @@ jobs: - name: Delete package specific version uses: smartsquaregmbh/delete-old-packages@v0.4.0 with: - version: 2.1.0 # This should be same as in the pom.xml file, + version: 2.1.1 # This should be same as in the pom.xml file, # to delete only the pom specified version, not the other older versions names: | com.uci.dao diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 844f3a4..fb32b43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,10 @@ name: Maven Build on: push: branches: - ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"] pull_request: branches: - ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"] jobs: build: diff --git a/pom.xml b/pom.xml index 3c82a32..10d17d2 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ dao dao jar - 2.1.0 + 2.1.1 From 446c830ab1da71a4191dd59ab80c8cc8a43d2bc3 Mon Sep 17 00:00:00 2001 From: pankajjangid05 Date: Thu, 27 Apr 2023 16:33:14 +0530 Subject: [PATCH 3/5] [Hot Fix] - Package version related changes --- .github/workflows/build-deploy.yml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index c160b60..5fc40ea 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -59,7 +59,7 @@ jobs: - name: Delete package specific version uses: smartsquaregmbh/delete-old-packages@v0.4.0 with: - version: 2.1.1 # This should be same as in the pom.xml file, + version: 2.1.0 # This should be same as in the pom.xml file, # to delete only the pom specified version, not the other older versions names: | com.uci.dao diff --git a/pom.xml b/pom.xml index 10d17d2..3c82a32 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ dao dao jar - 2.1.1 + 2.1.0 From 49a6622a31dd2cea897e12642e173ae256165336 Mon Sep 17 00:00:00 2001 From: pankajjangid05 Date: Wed, 3 May 2023 15:12:43 +0530 Subject: [PATCH 4/5] Creating new package naming for stagging and prod --- .github/workflows/build-deploy.yml | 4 ++-- pom.xml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 5fc40ea..d22ab9a 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -3,7 +3,7 @@ name: Github Package on: push: tags: - - 'v*.*.*' + ["v*.*.*", "v*.*.*-*"] branches: ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"] pull_request: @@ -59,7 +59,7 @@ jobs: - name: Delete package specific version uses: smartsquaregmbh/delete-old-packages@v0.4.0 with: - version: 2.1.0 # This should be same as in the pom.xml file, + version: 2.2.0-SNAPSHOT # This should be same as in the pom.xml file, # to delete only the pom specified version, not the other older versions names: | com.uci.dao diff --git a/pom.xml b/pom.xml index 3c82a32..0ce3614 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ dao dao jar - 2.1.0 + 2.2.0-SNAPSHOT @@ -99,13 +99,13 @@ com.uci message-rosa - 2.1.0 + 2.2.0-SNAPSHOT compile com.uci utils - 2.1.0 + 2.2.0-SNAPSHOT compile From 3263b94fb6336076ff230613472512ab2ffc9cff Mon Sep 17 00:00:00 2001 From: pankajjangid05 Date: Mon, 8 May 2023 15:50:13 +0530 Subject: [PATCH 5/5] [Prod Deployment] - Change Package version and merge development branch in master --- .github/workflows/build-deploy.yml | 2 +- pom.xml | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index d22ab9a..c60da52 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -59,7 +59,7 @@ jobs: - name: Delete package specific version uses: smartsquaregmbh/delete-old-packages@v0.4.0 with: - version: 2.2.0-SNAPSHOT # This should be same as in the pom.xml file, + version: 2.2.1 # This should be same as in the pom.xml file, # to delete only the pom specified version, not the other older versions names: | com.uci.dao diff --git a/pom.xml b/pom.xml index 0ce3614..b89602c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ dao dao jar - 2.2.0-SNAPSHOT + 2.2.1 @@ -21,6 +21,8 @@ 1.8 1.8 + 2.2.1 + 2.2.1 @@ -99,13 +101,13 @@ com.uci message-rosa - 2.2.0-SNAPSHOT + ${messagerosa.version} compile com.uci utils - 2.2.0-SNAPSHOT + ${utils.version} compile