aboutsummaryrefslogtreecommitdiffstats
path: root/ms
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:54:09 +0000
commit41f66ef2e223d4925d1dc94e3d898b308fdb560e (patch)
tree947109286317ca55f186ed6c88bcb8ce7c9e5cab /ms
parentbfca233b96801b53af015f3532fa73c615fef6e4 (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>
Diffstat (limited to 'ms')
-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])