aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-04-28 14:49:22 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-04-28 18:58:19 +0000
commit83edeed4748644314453654aa853ad5674fc899e (patch)
treebc03375c5b3a56481975f2db1b565516f2f71108
parent53239aeca32291b3b499a80e2f805bdf26f1ebcd (diff)
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 <jozsef.csongvai@bell.ca>
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt17
1 files changed, 14 insertions, 3 deletions
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<JsonNode> = 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])