Search in sources :

Example 1 with TaskStatus

use of com.epam.pipeline.entity.pipeline.TaskStatus in project cloud-pipeline by epam.

the class RunLogManager method saveLog.

@Transactional(propagation = Propagation.REQUIRED)
public RunLog saveLog(final RunLog runLog) {
    Assert.notNull(runLog.getRunId(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "runId", RunLog.class.getSimpleName()));
    Assert.notNull(runLog.getDate(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "date", RunLog.class.getSimpleName()));
    Assert.notNull(runLog.getStatus(), messageHelper.getMessage(MessageConstants.ERROR_PARAMETER_REQUIRED, "status", RunLog.class.getSimpleName()));
    PipelineRun run = pipelineRunDao.loadPipelineRun(runLog.getRunId());
    Assert.notNull(run, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, runLog.getRunId()));
    if (!StringUtils.isEmpty(runLog.getLogText())) {
        runLog.setLogText(runLog.getLogText().replaceAll("\\u0000", ""));
    }
    // Check previous status, it may differ from pod status as error may occur during
    // results upload to s3
    TaskStatus statusToSave = runLog.getStatus();
    if (!StringUtils.isEmpty(runLog.getTaskName())) {
        PipelineTask task = self.loadPreviousTaskStatus(run, runLog);
        if (task != null && task.getStatus().isFinal()) {
            statusToSave = task.getStatus();
        }
    }
    // this status
    if (!statusToSave.isFinal() && run.getStatus().isFinal()) {
        statusToSave = run.getStatus();
    }
    runLog.setStatus(statusToSave);
    runLogDao.createRunLog(runLog);
    return runLog;
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) TaskStatus(com.epam.pipeline.entity.pipeline.TaskStatus) PipelineTask(com.epam.pipeline.entity.pipeline.PipelineTask) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with TaskStatus

use of com.epam.pipeline.entity.pipeline.TaskStatus in project cloud-pipeline by epam.

the class PodMonitor method getPodLogs.

private void getPodLogs(PipelineRun pipelineRun, KubernetesClient client, Pod pod) {
    String log = "";
    TaskStatus status = getStatus(pipelineRun, pod);
    String instance = pod == null ? pipelineRun.getPodId() : pod.getMetadata().getName();
    try {
        if (pod != null) {
            LOGGER.debug("LOGS FOR POD: " + pod.getMetadata().getName());
            log = client.pods().inNamespace(kubeNamespace).withName(pod.getMetadata().getName()).getLog();
        }
    } catch (KubernetesClientException e) {
        LOGGER.debug(e.getMessage(), e);
    } finally {
        saveLog(pipelineRun, instance, log, status);
    }
}
Also used : TaskStatus(com.epam.pipeline.entity.pipeline.TaskStatus) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

TaskStatus (com.epam.pipeline.entity.pipeline.TaskStatus)2 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)1 PipelineTask (com.epam.pipeline.entity.pipeline.PipelineTask)1 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 Transactional (org.springframework.transaction.annotation.Transactional)1