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(); } }
n.put("podIp", ps.getPodIP()); n.put("qosClass", ps.getQosClass()); n.put("reason", ps.getReason()); n.put("startTime", ps.getStartTime());
public PodStatusBuilder(PodStatusFluent<?> fluent,PodStatus instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withConditions(instance.getConditions()); fluent.withContainerStatuses(instance.getContainerStatuses()); fluent.withHostIP(instance.getHostIP()); fluent.withMessage(instance.getMessage()); fluent.withPhase(instance.getPhase()); fluent.withPodIP(instance.getPodIP()); fluent.withReason(instance.getReason()); fluent.withStartTime(instance.getStartTime()); this.validationEnabled = validationEnabled; } public PodStatusBuilder(PodStatus instance){
public PodStatusFluentImpl(PodStatus instance){ this.withConditions(instance.getConditions()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withReason(instance.getReason()); this.withStartTime(instance.getStartTime()); }
public PodStatusBuilder(PodStatus instance,Boolean validationEnabled){ this.fluent = this; this.withConditions(instance.getConditions()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withReason(instance.getReason()); this.withStartTime(instance.getStartTime()); this.validationEnabled = validationEnabled; }
private PodStatus getPodStatus(String podName) { io.fabric8.kubernetes.api.model.PodStatus kubernetesPodStatus = kubernetesClient .pods() .inNamespace(environment.getKubernetesNamespace()) .withName(podName) .get() .getStatus(); PodStatus podStatus = new PodStatus(); podStatus.setName(podName); podStatus.setHostIp(kubernetesPodStatus.getHostIP()); podStatus.setPodIp(kubernetesPodStatus.getPodIP()); podStatus.setPhase(kubernetesPodStatus.getPhase()); podStatus.setReason(kubernetesPodStatus.getReason()); podStatus.setStartTime(kubernetesPodStatus.getStartTime()); podStatus.setHasJolokia(getPodJolokiaPort(podName).isPresent()); podStatus.setContainers(getPodContainerNames(podName)); return podStatus; }