io.fabric8.kubernetes.api.model.ContainerState Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.ContainerState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PodWatcher.java From data-highway with Apache License 2.0 | 6 votes |
@Override public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Pod pod) { log.info("Event received for pod: {}, action: {}", podName, action); PodStatus status = pod.getStatus(); List<ContainerStatus> containerStatuses = status.getContainerStatuses(); if (!containerStatuses.isEmpty()) { ContainerStatus containerStatus = containerStatuses.get(0); ContainerState state = containerStatus.getState(); ContainerStateTerminated terminated = state.getTerminated(); if (terminated != null) { Integer exitCode = terminated.getExitCode(); log.info("Container exit code for pod {}: {}", podName, exitCode); if (exitCode == 0) { exitCodeFuture.complete(0); } else { exitCodeFuture.completeExceptionally(new RuntimeException("Completed with non zero exit code: " + exitCode)); } resource.delete(); watch.close(); } else { log.warn("ContainerStateTerminated was null for pod: {}, action {}", podName, action); } } else { log.warn("ContainerStatus list was empty for pod: {}, action {}", podName, action); } }
Example #2
Source File: KubernetesPodEventTranslator.java From styx with Apache License 2.0 | 6 votes |
private static boolean isExited(Pod pod, Optional<ContainerStatus> mainContainerStatusOpt) { switch (pod.getStatus().getPhase()) { case "Running": // Check if the main container has exited if (mainContainerStatusOpt.map(ContainerStatus::getState) .map(ContainerState::getTerminated) .isPresent()) { return true; } break; case "Succeeded": case "Failed": return true; default: // do nothing break; } return false; }
Example #3
Source File: KubernetesLanderTest.java From data-highway with Apache License 2.0 | 5 votes |
private ContainerState terminatedStateWithExitCode(int exitCode) { ContainerStateTerminated terminated = new ContainerStateTerminated(); terminated.setExitCode(exitCode); ContainerState state = new ContainerState(); state.setTerminated(terminated); return state; }
Example #4
Source File: KubernetesPodEventTranslatorTest.java From styx with Apache License 2.0 | 4 votes |
private static ContainerState runningContainerState() { return new ContainerState(new ContainerStateRunning("2016-05-30T09:46:48Z"), null, null); }
Example #5
Source File: KubernetesPodEventTranslatorTest.java From styx with Apache License 2.0 | 4 votes |
static ContainerState terminatedContainerState(Integer exitCode, String message) { return new ContainerState(null, new ContainerStateTerminated("", exitCode, "", message, "", 0, ""), null); }
Example #6
Source File: KubernetesPodEventTranslatorTest.java From styx with Apache License 2.0 | 4 votes |
private static ContainerState waitingContainerState(String reason) { return waitingContainerState(reason, ""); }
Example #7
Source File: KubernetesPodEventTranslatorTest.java From styx with Apache License 2.0 | 4 votes |
private static ContainerState waitingContainerState(String reason, String message) { return new ContainerState(null, null, new ContainerStateWaiting(message, reason)); }