mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Added a method to verify no containers in a pod have failed. The density
test is modified to use this method. #7374
This commit is contained in:
parent
e0e83fa8fe
commit
caf70a28b4
@ -535,6 +535,9 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) error
|
||||
for _, p := range currentPods.Items {
|
||||
if p.Status.Phase == api.PodRunning {
|
||||
current++
|
||||
if err := VerifyContainersAreNotFailed(p); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if p.Status.Phase == api.PodPending {
|
||||
if p.Spec.Host == "" {
|
||||
waiting++
|
||||
@ -576,3 +579,23 @@ func listPods(c *client.Client, namespace string, label labels.Selector, field f
|
||||
}
|
||||
return pods, err
|
||||
}
|
||||
|
||||
func VerifyContainersAreNotFailed(pod api.Pod) error {
|
||||
var errStrings []string
|
||||
|
||||
statuses := pod.Status.ContainerStatuses
|
||||
if len(statuses) == 0 {
|
||||
return nil
|
||||
} else {
|
||||
for _, status := range statuses {
|
||||
if status.State.Termination != nil || status.LastTerminationState.Termination != nil || status.RestartCount != 0 {
|
||||
errStrings = append(errStrings, fmt.Sprintf("Error: Pod %s: Container %s was found to have terminated %d times", pod.Name, status.Name, status.RestartCount))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(errStrings) > 0 {
|
||||
return fmt.Errorf(strings.Join(errStrings, "\n"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user