diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index eccbf52b861bb32a6ce9aa92829ad1c2a3fe225b..495531f71b080fbb22f9c7256a012b8a8903178f 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -48,8 +48,14 @@ spec: cpu: "300m" readinessProbe: httpGet: - path: /api/partition/v1/swagger-ui.html - port: 80 + path: /actuator/health + port: 8081 + livenessProbe: + httpGet: + path: /actuator/health + port: 8081 + initialDelaySeconds: 250 + periodSeconds: 10 volumeMounts: - name: azure-keyvault mountPath: "/mnt/azure-keyvault" diff --git a/devops/azure/release.yaml b/devops/azure/release.yaml index b45c367aa116803839ec5b7d3aec78f6f36aee23..b0d07c9e19a5ebbb45f23e2e116aade86f0c8fa0 100644 --- a/devops/azure/release.yaml +++ b/devops/azure/release.yaml @@ -74,8 +74,14 @@ spec: - containerPort: 80 readinessProbe: httpGet: - path: /api/partition/v1/swagger-ui.html - port: 80 + path: /actuator/health + port: 8081 + livenessProbe: + httpGet: + path: /actuator/health + port: 8081 + initialDelaySeconds: 250 + periodSeconds: 10 volumeMounts: - name: azure-keyvault mountPath: "/mnt/azure-keyvault" diff --git a/docs/api/partition_openapi.yaml b/docs/api/partition_openapi.yaml index 13c47a88a266b4ac63d06d5b407bd1346c58fb63..df9712e0b20e57538718224d6cc82cf75b29a713 100644 --- a/docs/api/partition_openapi.yaml +++ b/docs/api/partition_openapi.yaml @@ -16,7 +16,7 @@ tags: - name: health-check description: Health Check paths: - /_ah/liveness_check: + /actuator/health: get: tags: - health-check @@ -40,7 +40,7 @@ paths: security: - JWT: - global - /_ah/readiness_check: + /actuator/health: get: tags: - health-check diff --git a/docs/tutorial/Partition.md b/docs/tutorial/Partition.md index 516bd50b0c34fb8aff9404ad6bbef5b61c40326d..d3bad4589a346fd08ca19d17455f9e4ab9e6b453 100644 --- a/docs/tutorial/Partition.md +++ b/docs/tutorial/Partition.md @@ -18,13 +18,13 @@ Partition service is responsible for creating and retrieving the partition speci ## Health Check <a name="checking-service-health"></a> An endpoint to check if service is up and running. ``` -GET api/partition/v1/_ah/liveness_check +GET api/partition/v1/actuator/health ``` <details><summary>curl</summary> ``` curl --request GET \ - --url 'https://<base_url>/api/partition/v1/_ah/liveness_check' + --url 'https://<base_url>/api/partition/v1/actuator/health' ``` </details> diff --git a/partition-core/pom.xml b/partition-core/pom.xml index a685b5d85edb6bd72db40d5da0967f054a2c7a5f..a92db618be849b5ab942f32631f1b4f8bd83e8ac 100644 --- a/partition-core/pom.xml +++ b/partition-core/pom.xml @@ -56,6 +56,10 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> diff --git a/partition-core/src/main/java/org/opengroup/osdu/partition/api/HealthCheck.java b/partition-core/src/main/java/org/opengroup/osdu/partition/api/HealthCheck.java deleted file mode 100644 index f76c6b02c59495e6604bc605a095b3add06bd543..0000000000000000000000000000000000000000 --- a/partition-core/src/main/java/org/opengroup/osdu/partition/api/HealthCheck.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017-2020, Schlumberger -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.opengroup.osdu.partition.api; - -import java.util.Collections; -import org.opengroup.osdu.partition.logging.AuditLogger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(path= "/_ah", produces = "application/json") -public class HealthCheck { - - @Autowired - private AuditLogger auditLogger; - - @GetMapping("/liveness_check") - public ResponseEntity<String> livenessCheck() { - ResponseEntity responseEntity = new ResponseEntity<>("Partition service is alive", HttpStatus.OK); - this.auditLogger.readServiceLivenessSuccess(Collections.singletonList(responseEntity.toString())); - return responseEntity; - } - - @GetMapping("/readiness_check") - public ResponseEntity<String> readinessCheck() { - return new ResponseEntity<>("Partition service is ready", HttpStatus.OK); - } -} diff --git a/partition-core/src/test/java/org/opengroup/osdu/partition/api/HealthCheckTest.java b/partition-core/src/test/java/org/opengroup/osdu/partition/api/HealthCheckTest.java deleted file mode 100644 index f21eaf8b7bb4fb81cd88cb9e48e5ed268ee16719..0000000000000000000000000000000000000000 --- a/partition-core/src/test/java/org/opengroup/osdu/partition/api/HealthCheckTest.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017-2020, Schlumberger -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.opengroup.osdu.partition.api; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.opengroup.osdu.partition.logging.AuditLogger; -import org.springframework.http.HttpStatus; - -@RunWith(MockitoJUnitRunner.class) -public class HealthCheckTest { - - @Mock - private AuditLogger auditLogger; - - @InjectMocks - private HealthCheck sut; - - @Test - public void should_returnHttp200_when_checkLiveness() { - assertEquals(HttpStatus.OK, this.sut.livenessCheck().getStatusCode()); - } - - @Test - public void should_returnHttp200_when_checkReadiness() { - assertEquals(HttpStatus.OK, this.sut.readinessCheck().getStatusCode()); - } -} \ No newline at end of file diff --git a/provider/partition-aws/pom.xml b/provider/partition-aws/pom.xml index 429e74dcb7dd3ee6dab00ea142f11daac4eacafc..85dc54ca4ea305992c858bef8cc7aa6900db7fa2 100644 --- a/provider/partition-aws/pom.xml +++ b/provider/partition-aws/pom.xml @@ -93,10 +93,6 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-client</artifactId> diff --git a/provider/partition-azure/README.md b/provider/partition-azure/README.md index e5753d1cbbbcb839d11efba13c10e6e67e301837..8ec2ef3e4ac35ec0dee5c637f9023d55a9c42055 100644 --- a/provider/partition-azure/README.md +++ b/provider/partition-azure/README.md @@ -107,7 +107,7 @@ $ (cd testing/partition-test-core/ && mvn clean install) $ (cd testing/partition-test-azure/ && mvn clean test) ``` -A liveness check can also be performed at `http://localhost:8080/api/partition/v1/_ah/liveness_check`. Other apis can be found on the swagger page +A liveness check can also be performed at `http://localhost:8080/api/partition/v1/actuator/health`. Other apis can be found on the swagger page ## Debugging diff --git a/provider/partition-azure/devops/stages.yml b/provider/partition-azure/devops/stages.yml index 8ea1600127379a49d207d091d45dbf958167f77e..f8f8b205a6e1e76b4c44762f98cddde9e7efff8c 100644 --- a/provider/partition-azure/devops/stages.yml +++ b/provider/partition-azure/devops/stages.yml @@ -151,7 +151,7 @@ stages: attempt_counter=0 max_attempts=60 # NOTE that the PARTITION_BASE_URL already has a '/' at the end of it - until [ $(curl -s -o /dev/null -w "%{http_code}" $(PARTITION_BASE_URL)api/partition/v1/_ah/liveness_check) -eq 200 ]; do + until [ $(curl -s -o /dev/null -w "%{http_code}" $(PARTITION_BASE_URL)api/partition/v1/actuator/health) -eq 200 ]; do if [ ${attempt_counter} -eq ${max_attempts} ];then echo "Service is not available, please check the deployment" exit 1 diff --git a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/security/AADSecurityConfig.java b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/security/AADSecurityConfig.java index 427dccaa90a29451ba5f61d3cf72f852a3acc2c4..ba916caea6eb66b0e9bb2dd4789825cf8393dbe4 100644 --- a/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/security/AADSecurityConfig.java +++ b/provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/security/AADSecurityConfig.java @@ -40,7 +40,7 @@ public class AADSecurityConfig extends WebSecurityConfigurerAdapter { .and() .authorizeRequests() .antMatchers("/", "/index.html", - "/_ah/*", + "/actuator/*", "/api-docs", "/configuration/ui", "/swagger-resources/**", diff --git a/provider/partition-azure/src/main/resources/application.properties b/provider/partition-azure/src/main/resources/application.properties index 3c241d5981d8c070f66ec74b4a4042098b3728db..7da879f59be16d728b121d0226f59f795cc03381 100644 --- a/provider/partition-azure/src/main/resources/application.properties +++ b/provider/partition-azure/src/main/resources/application.properties @@ -36,6 +36,10 @@ redis.ssl.enabled=true redis.connection.timeout=15 redis.database=${REDIS_DATABASE} +# health check +management.health.azure-key-vault.enabled=false +management.server.port=8081 + azure.cryptography.enabled=false azure.eventgrid.topic.enabled=false azure.eventgrid.manager.enabled=false diff --git a/provider/partition-gcp/pom.xml b/provider/partition-gcp/pom.xml index 9d0b516b0c78fff8666d4c3a41c590d969341790..6ae38e85ea3ff8785a8f9d0e7a41135da01a33b7 100644 --- a/provider/partition-gcp/pom.xml +++ b/provider/partition-gcp/pom.xml @@ -42,10 +42,6 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-client</artifactId> diff --git a/provider/partition-ibm/pom.xml b/provider/partition-ibm/pom.xml index c58d1b2d25becbb8af7d351317e43b100cd59333..e2a911ee4cf48fc09dab1aa987bb1a8a60c861e1 100644 --- a/provider/partition-ibm/pom.xml +++ b/provider/partition-ibm/pom.xml @@ -41,10 +41,6 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-client</artifactId> diff --git a/provider/partition-ibm/src/main/resources/application.properties b/provider/partition-ibm/src/main/resources/application.properties index 59435cdad0effbce72555aa61219cea468c88adf..cd94f42510f955f18220975ac63b507de37940d7 100644 --- a/provider/partition-ibm/src/main/resources/application.properties +++ b/provider/partition-ibm/src/main/resources/application.properties @@ -15,7 +15,7 @@ cache.provider=vm cache.expiration=1 cache.maxSize=1000 -ibm.health-check-uri=/api/partition/v1/_ah/liveness_check,/api/partition/v1/_ah/readiness_check +ibm.health-check-uri=/api/partition/v1/actuator/health,/api/partition/v1/actuator/health excluded.uris.for.partition-filter=/api/partition/v1/partitions #Database Configuration