From 316a5e5a3cb74d4299e6a6c9a32648aead37e98a Mon Sep 17 00:00:00 2001 From: "j.blixt" Date: Wed, 31 Mar 2021 11:48:49 +0200 Subject: [vFW_CNF_CDS] Add workflow health-check and K8sHealthCheck.kt script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: INT-1899 Signed-off-by: j.blixt Signed-off-by: Grzegorz Wielgosinski Signed-off-by: Konrad Bańka Change-Id: I7d52c49bd0e40d30a560b2012362d38488392be6 (cherry picked from commit 532cfff8eaad73781cbb410064cd3b4bda5e3095) --- .../templates/cba/Scripts/kotlin/SimpleStatusCheck.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt') diff --git a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt index 90330644..e2d10534 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt +++ b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt @@ -40,7 +40,7 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode val bluePrintPropertiesService: BlueprintPropertiesService = - this.functionDependencyInstanceAsType("blueprintPropertiesService") + this.functionDependencyInstanceAsType("blueprintPropertiesService") val k8sConfiguration = K8sConnectionPluginConfiguration(bluePrintPropertiesService) @@ -54,7 +54,10 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { val instanceName = it.value.get("k8s-instance-id").asText() val instanceStatus: K8sRbInstanceStatus? = instanceApi.getInstanceStatus(instanceName) + log.debug("Get status for $instanceName") + var status = "" instanceStatus?.resourcesStatus?.forEach { + log.debug("Resource: name=$it.name kind=$it.gvk.kind group=$it.gvk.group version=$it.gvk.version") if (it.gvk?.kind == "Pod") { var version = it.gvk?.version!! if (it.gvk?.group!! != "") @@ -62,10 +65,12 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { // val podStatus = instanceApi.queryInstanceStatus(instanceName, it.gvk?.kind!!, version, it.name, null) // log.info(podStatus.toString()) val podState = it.status?.get("status") as Map - - if ((podState["phase"] as String) != "Running") { + status = podState["phase"] as String + if (status != "Running") { continueCheck = true - log.info("Pod ${it.name} [$vfModuleName] has invalid state ${(podState["phase"])}") + log.info("Pod ${it.name} [$vfModuleName] has INVALID state ${(podState["phase"])}") + } else { + log.info("Pod ${it.name} [$vfModuleName] has VALID state ${(podState["phase"])}") } } } @@ -79,7 +84,7 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { checkCount = 0 } - log.info("SIMPLE STATUS CHECK - END") + log.info("SIMPLE STATUS CHECK - END SUCCESS") } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { -- cgit 1.2.3-korg