@Override public Event toEvent() { return Event.runError(WorkflowInstance.parseKey(workflowInstance), message); } }
private static Optional<Event> isInErrorState(WorkflowInstance workflowInstance, Pod pod, Optional<ContainerStatus> mainContainerStatusOpt) { final PodStatus status = pod.getStatus(); final String phase = status.getPhase(); if ("NodeLost".equals(pod.getStatus().getReason())) { return Optional.of(Event.runError(workflowInstance, "Lost node running pod")); } switch (phase) { case "Pending": // check if one or more docker contains failed to pull their image, a possible silent error return mainContainerStatusOpt .filter(KubernetesPodEventTranslator::hasPullImageError) .map(x -> Event.runError(workflowInstance, "One or more containers failed to pull their image")); case "Succeeded": case "Failed": if (!mainContainerStatusOpt.isPresent()) { return Optional.of(Event.runError(workflowInstance, "Could not find our container in pod")); } final ContainerStatus containerStatus = mainContainerStatusOpt.get(); final ContainerStateTerminated terminated = containerStatus.getState().getTerminated(); if (terminated == null) { return Optional.of(Event.runError(workflowInstance, "Unexpected null terminated status")); } return Optional.empty(); case "Unknown": return Optional.of(Event.runError(workflowInstance, "Pod entered Unknown phase")); default: return Optional.empty(); } }
private void examineRunningWFISandAssociatedPods(Map<WorkflowInstance, RunState> activeStates, PodList podList) { final Map<WorkflowInstance, RunState> runningWorkflowInstances = Maps.filterValues(activeStates, runState -> runState.state().equals(RUNNING) && runState.data().executionId().isPresent()); final Set<WorkflowInstance> workflowInstancesForPods = podList.getItems().stream() .map(pod -> pod.getMetadata().getAnnotations()) .filter(Objects::nonNull) .map(annotations -> annotations.get(STYX_WORKFLOW_INSTANCE_ANNOTATION)) .filter(Objects::nonNull) .map(WorkflowInstance::parseKey) .collect(toSet()); // Emit errors for workflow instances that seem to be missing its pod runningWorkflowInstances.forEach((workflowInstance, runState) -> { // Is there a matching pod in the list? Bail. if (workflowInstancesForPods.contains(workflowInstance)) { return; } // The pod list might be stale so explicitly look for a pod using the execution ID. final String executionId = runState.data().executionId().get(); final Pod pod = client.pods().withName(executionId).get(); // We found a pod? Bail. if (pod != null) { return; } // No pod found. Emit an error guarded by the state counter we are basing the error conclusion on. stateManager.receiveIgnoreClosed( Event.runError(workflowInstance, "No pod associated with this instance"), runState.counter()); }); }
Event.runError(instanceState.workflowInstance(), String.format("Referenced resources not found: %s", unknownResources)), instanceState.runState().counter());
try { LOG.error("Failed to retrieve execution description for " + state.workflowInstance(), e); stateManager.receive(Event.runError(state.workflowInstance(), e.getMessage())); } catch (IsClosedException isClosedException) { LOG.warn("Failed to send 'runError' event", isClosedException);
LOG.error(msg, e); stateManager.receive(Event.runError(state.workflowInstance(), e.getMessage()), state.counter() + 1); } catch (IsClosedException isClosedException) {