From 41f66ef2e223d4925d1dc94e3d898b308fdb560e Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Wed, 28 Apr 2021 14:49:22 -0400 Subject: Add check for cluster status to readiness endpoint When Cluster is enabled, BlueprintsProcessor should not process any requests until cluster is fully joined. Issue-ID: CCSDK-3275 Change-Id: I779159346976f7af0c0add69883f27d7f359f413 Signed-off-by: Jozsef Csongvai --- .../selfservice/api/ExecutionServiceController.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api') diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index 7628da214..6c6c26c43 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -24,11 +24,14 @@ import io.swagger.annotations.ApiParam import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput +import org.onap.ccsdk.cds.blueprintsprocessor.core.cluster.optionalClusterService import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.mdcWebCoroutineScope import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.MediaType @@ -64,8 +67,16 @@ open class ExecutionServiceController { ) @ResponseBody @ApiOperation(value = "Health Check", hidden = true) - suspend fun executionServiceControllerHealthCheck(): JsonNode = mdcWebCoroutineScope { - "Success".asJsonPrimitive() + suspend fun executionServiceControllerHealthCheck(): ResponseEntity = mdcWebCoroutineScope { + var body = mutableMapOf("success" to true) + var statusCode = 200 + if (BlueprintConstants.CLUSTER_ENABLED && + BlueprintDependencyService.optionalClusterService()?.clusterJoined() != true + ) { + statusCode = 503 + body.remove("success") + } + ResponseEntity.status(statusCode).body(body.asJsonType()) } @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE]) -- cgit 1.2.3-korg