Search in sources :

Example 1 with Problem

use of com.netflix.spinnaker.halyard.core.problem.v1.Problem in project halyard by spinnaker.

the class OrcaRunner method monitor.

private void monitor(Supplier<Pipeline> getPipeline) {
    String status;
    Pipeline pipeline;
    Set<String> loggedTasks = new HashSet<>();
    try {
        pipeline = getPipeline.get();
        status = pipeline.getStatus();
        while (status.equalsIgnoreCase("running") || status.equalsIgnoreCase("not_started")) {
            logPipelineOutput(pipeline, loggedTasks);
            DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(10));
            pipeline = getPipeline.get();
            status = pipeline.getStatus();
        }
    } catch (RetrofitError e) {
        throw new HalException(new ProblemBuilder(Problem.Severity.FATAL, "Failed to monitor task: " + e.getMessage()).build());
    }
    logPipelineOutput(pipeline, loggedTasks);
    if (status.equalsIgnoreCase("terminal")) {
        Problem problem = findExecutionError(pipeline);
        throw new HalException(problem);
    }
}
Also used : HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) RetrofitError(retrofit.RetrofitError) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Example 2 with Problem

use of com.netflix.spinnaker.halyard.core.problem.v1.Problem in project halyard by spinnaker.

the class ResponseUnwrapper method formatProblemSet.

private static void formatProblemSet(ProblemSet problemSet) {
    if (problemSet == null || problemSet.isEmpty()) {
        return;
    }
    AnsiSnippet snippet = new AnsiSnippet("\r").setErase(AnsiErase.ERASE_LINE);
    AnsiPrinter.err.print(snippet.toString());
    Map<String, List<Problem>> locationGroup = problemSet.groupByLocation();
    for (Entry<String, List<Problem>> entry : locationGroup.entrySet()) {
        AnsiUi.problemLocation(entry.getKey());
        for (Problem problem : entry.getValue()) {
            Severity severity = problem.getSeverity();
            String message = problem.getMessage();
            String remediation = problem.getRemediation();
            List<String> options = problem.getOptions();
            switch(severity) {
                case FATAL:
                case ERROR:
                    AnsiUi.error(message);
                    break;
                case WARNING:
                    AnsiUi.warning(message);
                    break;
                default:
                    throw new RuntimeException("Unknown severity level " + severity);
            }
            if (remediation != null && !remediation.isEmpty()) {
                AnsiUi.remediation(remediation);
            }
            if (options != null && !options.isEmpty()) {
                AnsiUi.remediation("Options include: ");
                options.forEach(AnsiUi::listRemediation);
            }
            // Newline between errors
            AnsiUi.raw("");
        }
    }
}
Also used : Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) Severity(com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity)

Example 3 with Problem

use of com.netflix.spinnaker.halyard.core.problem.v1.Problem in project halyard by spinnaker.

the class OrcaRunner method findError.

private static Problem findError(HasContext hasContext) {
    if (hasContext == null) {
        return null;
    }
    Context context = hasContext.getContext();
    if (context == null) {
        return null;
    }
    ExecutionException exception = context.getException();
    if (exception == null) {
        return null;
    }
    StringBuilder message = new StringBuilder();
    String operation = exception.getOperation();
    if (operation != null) {
        message.append(formatId(operation)).append(": ");
    }
    ExecutionException.Details details = exception.getDetails();
    if (details == null) {
        message.append("No error details found.");
    } else {
        message.append("(").append(details.getError()).append(") ");
        for (String error : details.getErrors()) {
            message.append(error).append(" ");
        }
    }
    return new ProblemBuilder(Problem.Severity.FATAL, message.toString()).build();
}
Also used : ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Example 4 with Problem

use of com.netflix.spinnaker.halyard.core.problem.v1.Problem in project halyard by spinnaker.

the class DaemonTask method failure.

public void failure(Exception e) {
    inFailedState();
    fatalError = e;
    Problem problem = new ProblemBuilder(Problem.Severity.FATAL, "Unexpected exception: " + e).build();
    response = new DaemonResponse<>(null, new ProblemSet(problem));
}
Also used : Problem(com.netflix.spinnaker.halyard.core.problem.v1.Problem) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) ProblemBuilder(com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)

Aggregations

Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)3 ProblemBuilder (com.netflix.spinnaker.halyard.core.problem.v1.ProblemBuilder)3 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 Severity (com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 RetrofitError (retrofit.RetrofitError)1