Search in sources :

Example 21 with ContainerStateTerminated

use of io.fabric8.kubernetes.api.model.ContainerStateTerminated in project styx by spotify.

the class KubernetesDockerRunnerTest method shouldForceCleanupPodAfterPodForceDeletionTolerationPassed.

@Parameters({ "TERMINATED", "FAILED", "ERROR", "DONE" })
@Test
public void shouldForceCleanupPodAfterPodForceDeletionTolerationPassed(String stateName) {
    final State state = State.valueOf(stateName);
    // inject mock status in real instance
    createdPod.setStatus(podStatus);
    when(podStatus.getContainerStatuses()).thenReturn(List.of(keepaliveContainerStatus, containerStatus));
    when(containerStatus.getName()).thenReturn(MAIN_CONTAINER_NAME);
    when(containerStatus.getState()).thenReturn(containerState);
    when(containerState.getTerminated()).thenReturn(containerStateTerminated);
    when(containerStateTerminated.getFinishedAt()).thenReturn(FIXED_INSTANT.minus(Duration.ofMinutes(35)).toString());
    var runState = RunState.create(WORKFLOW_INSTANCE, state);
    var shouldDelete = kdr.shouldDeletePodWithRunState(WORKFLOW_INSTANCE, createdPod, runState);
    assertThat(shouldDelete, is(PodDeletionDecision.FORCE_DELETE));
}
Also used : RunState(com.spotify.styx.state.RunState) State(com.spotify.styx.state.RunState.State) ContainerState(io.fabric8.kubernetes.api.model.ContainerState) KubernetesPodEventTranslatorTest.terminatedContainerState(com.spotify.styx.docker.KubernetesPodEventTranslatorTest.terminatedContainerState) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

ContainerStateTerminated (io.fabric8.kubernetes.api.model.ContainerStateTerminated)12 Pod (io.fabric8.kubernetes.api.model.Pod)12 Test (org.junit.Test)8 ContainerStatus (io.fabric8.kubernetes.api.model.ContainerStatus)6 ContainerState (io.fabric8.kubernetes.api.model.ContainerState)5 RunState (com.spotify.styx.state.RunState)4 PodStatus (io.fabric8.kubernetes.api.model.PodStatus)4 Objects (java.util.Objects)4 KubernetesPodEventTranslatorTest.terminatedContainerState (com.spotify.styx.docker.KubernetesPodEventTranslatorTest.terminatedContainerState)3 State (com.spotify.styx.state.RunState.State)3 LocalObjectReference (io.fabric8.kubernetes.api.model.LocalObjectReference)3 List (java.util.List)3 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 ContainerStateWaiting (io.fabric8.kubernetes.api.model.ContainerStateWaiting)2 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 Build (io.fabric8.openshift.api.model.Build)2 KafkaConnectResources (io.strimzi.api.kafka.model.KafkaConnectResources)2 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)2 ClusterOperatorConfig (io.strimzi.operator.cluster.ClusterOperatorConfig)2