use of com.walmartlabs.concord.agent.logging.ProcessLog in project concord by walmartlabs.
the class RunnerJobExecutor method exec.
private void exec(RunnerJob job, ProcessEntry pe) throws Exception {
// the actual OS process
Process proc = pe.getProcess();
UUID instanceId = job.getInstanceId();
ProcessLog processLog = job.getLog();
// start the log's maintenance thread (e.g. streaming to the server)
LogStream logStream = new LogStream(job, proc);
logStream.start();
try {
// save the process' log
processLog.log(proc.getInputStream());
// wait for the process to finish
int code;
try {
code = proc.waitFor();
} catch (Exception e) {
// wait for the log to finish
logStream.waitForCompletion();
handleError(job, proc, e.getMessage());
throw new ExecutionException("Error while executing a job: " + e.getMessage());
}
// wait for the log to finish
logStream.waitForCompletion();
if (code != 0) {
log.warn("exec ['{}'] -> finished with {}", instanceId, code);
handleError(job, proc, "Process exit code: " + code);
throw new ExecutionException("Error while executing a job, process exit code: " + code);
}
log.info("exec ['{}'] -> finished with {}", instanceId, code);
processLog.info("Process finished with: {}", code);
} finally {
// wait for the log to finish
logStream.waitForCompletion();
}
}
use of com.walmartlabs.concord.agent.logging.ProcessLog in project concord by walmartlabs.
the class RunnerJobExecutor method validateDependencies.
private void validateDependencies(RunnerJob job, Collection<DependencyEntity> resolvedDepEntities) throws ExecutionException {
PolicyEngine policyEngine = job.getPolicyEngine();
if (policyEngine == null) {
return;
}
ProcessLog processLog = job.getLog();
processLog.info("Checking the dependency policy...");
CheckResult<DependencyRule, DependencyEntity> result = policyEngine.getDependencyPolicy().check(resolvedDepEntities);
result.getWarn().forEach(d -> processLog.warn("Potentially restricted artifact '{}' (dependency policy: {})", d.getEntity(), d.getRule().getMsg()));
result.getDeny().forEach(d -> processLog.warn("Artifact '{}' is forbidden by the dependency policy {}", d.getEntity(), d.getRule().getMsg()));
if (!result.getDeny().isEmpty()) {
throw new ExecutionException("Found restricted dependencies");
}
}
Aggregations