Skip to content

Commit

Permalink
Fail if Contianer got terminated (#5393)
Browse files Browse the repository at this point in the history
* Fail if Contianer got terminated

* Checking for teminating containers only for RunningPods
  • Loading branch information
Ilya Kislenko authored Apr 12, 2019
1 parent 72db82c commit 918cdbe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CreatePod(ctx context.Context, cli kubernetes.Interface, opts *PodOptions)
},
Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
{
Name: "container",
Image: opts.Image,
Command: opts.Command,
Expand Down Expand Up @@ -103,6 +103,13 @@ func WaitForPodCompletion(ctx context.Context, cli kubernetes.Interface, namespa
if p.Status.Phase == v1.PodFailed {
return false, errors.Errorf("Pod %s failed", name)
}
if p.Status.Phase == v1.PodRunning {
for _, con := range p.Status.ContainerStatuses {
if con.State.Terminated != nil {
return false, errors.Errorf("Container %v is terminated, while Pod %v is Running", con.Name, name)
}
}
}
return (p.Status.Phase == v1.PodSucceeded), nil
})
if err == nil {
Expand Down

0 comments on commit 918cdbe

Please sign in to comment.