mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
Add e2e_node test for oom killed container reason
This commit is contained in:
@@ -241,3 +241,23 @@ func FindPodConditionByType(podStatus *v1.PodStatus, conditionType v1.PodConditi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindContainerStatusInPod finds a container status by its name in the provided pod
|
||||
func FindContainerStatusInPod(pod *v1.Pod, containerName string) *v1.ContainerStatus {
|
||||
for _, containerStatus := range pod.Status.InitContainerStatuses {
|
||||
if containerStatus.Name == containerName {
|
||||
return &containerStatus
|
||||
}
|
||||
}
|
||||
for _, containerStatus := range pod.Status.ContainerStatuses {
|
||||
if containerStatus.Name == containerName {
|
||||
return &containerStatus
|
||||
}
|
||||
}
|
||||
for _, containerStatus := range pod.Status.EphemeralContainerStatuses {
|
||||
if containerStatus.Name == containerName {
|
||||
return &containerStatus
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -651,13 +651,13 @@ func (v *podStartVerifier) Verify(event watch.Event) error {
|
||||
return fmt.Errorf("pod %s on node %s had incorrect containers: %#v", pod.Name, pod.Spec.NodeName, pod.Status.ContainerStatuses)
|
||||
}
|
||||
|
||||
if status := findContainerStatusInPod(pod, "blocked"); status != nil {
|
||||
if status := e2epod.FindContainerStatusInPod(pod, "blocked"); status != nil {
|
||||
if (status.Started != nil && *status.Started == true) || status.LastTerminationState.Terminated != nil || status.State.Waiting == nil {
|
||||
return fmt.Errorf("pod %s on node %s should not have started the blocked container: %#v", pod.Name, pod.Spec.NodeName, status)
|
||||
}
|
||||
}
|
||||
|
||||
status := findContainerStatusInPod(pod, "fail")
|
||||
status := e2epod.FindContainerStatusInPod(pod, "fail")
|
||||
if status == nil {
|
||||
return fmt.Errorf("pod %s on node %s had incorrect containers: %#v", pod.Name, pod.Spec.NodeName, pod.Status)
|
||||
}
|
||||
@@ -741,23 +741,3 @@ func (v *podStartVerifier) VerifyFinal(scenario string, total time.Duration) (*v
|
||||
framework.Logf("Pod %s on node %s %s total=%s run=%s execute=%s", pod.Name, pod.Spec.NodeName, scenario, total, v.completeDuration, v.duration)
|
||||
return pod, errs
|
||||
}
|
||||
|
||||
// findContainerStatusInPod finds a container status by its name in the provided pod
|
||||
func findContainerStatusInPod(pod *v1.Pod, containerName string) *v1.ContainerStatus {
|
||||
for _, container := range pod.Status.InitContainerStatuses {
|
||||
if container.Name == containerName {
|
||||
return &container
|
||||
}
|
||||
}
|
||||
for _, container := range pod.Status.ContainerStatuses {
|
||||
if container.Name == containerName {
|
||||
return &container
|
||||
}
|
||||
}
|
||||
for _, container := range pod.Status.EphemeralContainerStatuses {
|
||||
if container.Name == containerName {
|
||||
return &container
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user