RemoteAnsibleExecutor delay vs Thread.sleep bug 80/109680/1
authorOleg Mitsura <oleg.mitsura@amdocs.com>
Tue, 30 Jun 2020 12:46:35 +0000 (08:46 -0400)
committerOleg Mitsura <oleg.mitsura@amdocs.com>
Tue, 30 Jun 2020 12:48:25 +0000 (08:48 -0400)
Issue-ID: CCSDK-2505

Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com>
Change-Id: I0115a484c61169f2cc031553ecd664796aff6bf8

ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt

index 6f994ed..1e70cdd 100644 (file)
@@ -20,6 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.ObjectMapper
 import com.fasterxml.jackson.databind.node.TextNode
+import kotlinx.coroutines.delay
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
@@ -172,7 +173,7 @@ open class ComponentRemoteAnsibleExecutor(
      * its execution. Finally, it retrieves the job results via the stdout api.
      * The status and output attributes are populated in the process.
      */
-    private fun runJobTemplateOnAWX(
+    private suspend fun runJobTemplateOnAWX(
         awxClient: BlueprintWebClientService,
         job_template_name: String?,
         jtId: String,
@@ -210,7 +211,7 @@ open class ComponentRemoteAnsibleExecutor(
                 val jobLaunched: JsonNode = mapper.readTree(response.body)
                 jobStatus = jobLaunched.at("/status").asText()
                 jobEndTime = jobLaunched.at("/finished").asText()
-                Thread.sleep(checkDelay)
+                delay(checkDelay)
             }
 
             log.info("Execution of job template $job_template_name in job #$jobId finished with status ($jobStatus) for requestId $processId")