Search in sources :

Example 6 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class CmdExecutor method execute.

@Override
public void execute(StageExecutorRequest request, StageExecutorResultCallback resultCallback) {
    CmdRunner cmdRunner = CmdRunner.create(getExecutorParams());
    StageExecutorResult result = cmdRunner.execute(cmd);
    if (getExecutorParams().getPermanentErrors().contains(Ints.tryParse(result.getAttribute(EXIT_CODE)))) {
        result.setPermanentError();
    }
    resultCallback.accept(result);
}
Also used : CmdRunner(pipelite.executor.cmd.CmdRunner) StageExecutorResult(pipelite.stage.executor.StageExecutorResult)

Example 7 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AbstractLsfExecutor method recoverJobUsingOutFile.

private static boolean recoverJobUsingOutFile(CmdRunner cmdRunner, JobResult jobResult, Map<String, LsfDescribeJobsCache.RequestContext> requestMap) {
    String outFile = requestMap.get(jobResult.jobId).getOutFile();
    StageExecutorResult executorResult = extractResultFromOutFile(cmdRunner, outFile);
    if (executorResult != null) {
        log.atInfo().log("Recovered job result from LSF output file " + outFile + " for job: " + jobResult.jobId);
        jobResult.result = executorResult;
        return true;
    } else {
        log.atWarning().log("Could not recover job result from LSF output file " + outFile + "  for job: " + jobResult.jobId);
        log.atWarning().log("Considering LSF job failed as could not extract result for job: " + jobResult.jobId);
        jobResult.result = StageExecutorResult.error();
        return false;
    }
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult)

Example 8 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class AwsBatchExecutor method poll.

@Override
protected StageExecutorResult poll(StageExecutorRequest request) {
    String jobId = getJobId();
    logContext(log.atFine(), request).log("Polling AWSBatch job result " + jobId);
    StageExecutorResult result = describeJobs().getResult(jobId, getExecutorParams().getPermanentErrors());
    if (result.isActive()) {
        return StageExecutorResult.active();
    }
    if (isSaveLogFile(result)) {
    // TODO: save log
    }
    return result;
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult)

Example 9 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class LocalCmdRunnerTest method echo.

@Test
public void echo() {
    LocalCmdRunner cmdRunner = new LocalCmdRunner(CmdExecutorParameters.builder().build());
    StageExecutorResult result = cmdRunner.execute("echo test");
    assertThat(result.isError()).isFalse();
    assertThat(result.getAttribute(StageExecutorResultAttribute.EXIT_CODE)).isEqualTo("0");
    assertThat(result.getStageLog()).startsWith("test");
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Test(org.junit.jupiter.api.Test)

Example 10 with StageExecutorResult

use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.

the class LocalCmdRunnerTest method unknownCommand.

@Test
public void unknownCommand() {
    LocalCmdRunner cmdRunner = new LocalCmdRunner(CmdExecutorParameters.builder().build());
    StageExecutorResult result = cmdRunner.execute(PipeliteIdCreator.id());
    assertThat(result.isError()).isTrue();
    assertThat(result.getAttribute(StageExecutorResultAttribute.EXIT_CODE)).isNotEqualTo("0");
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) Test(org.junit.jupiter.api.Test)

Aggregations

StageExecutorResult (pipelite.stage.executor.StageExecutorResult)33 Test (org.junit.jupiter.api.Test)14 PipeliteException (pipelite.exception.PipeliteException)5 Stage (pipelite.stage.Stage)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)3 Collectors (java.util.stream.Collectors)3 IntStream (java.util.stream.IntStream)3 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)3 Mockito.mock (org.mockito.Mockito.mock)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)3 InternalErrorService (pipelite.service.InternalErrorService)3 Pod (io.fabric8.kubernetes.api.model.Pod)2 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 ZonedDateTime (java.time.ZonedDateTime)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 StageEntity (pipelite.entity.StageEntity)2 ContainerStatus (io.fabric8.kubernetes.api.model.ContainerStatus)1