Skip to content

Commit

Permalink
fix: for readiness check both the phase and ready status
Browse files Browse the repository at this point in the history
Observed that the ready status = true when the pod is terminating.
  • Loading branch information
deepthidevaki committed Dec 7, 2022
1 parent f62c5b7 commit c82a71e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions go-chaos/internal/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (c K8Client) checkIfBrokersAreRunning() (bool, error) {

allRunning := true
for _, pod := range pods.Items {
if !pod.Status.ContainerStatuses[0].Ready { // assuming there is only one container
LogVerbose("Pod %s is in phase %s, but not ready. Wait for some seconds.", pod.Name, pod.Status.Phase)
if pod.Status.Phase != v1.PodRunning || !pod.Status.ContainerStatuses[0].Ready { // assuming there is only one container
LogVerbose("Pod %s is in phase %s, and not ready. Wait for some seconds.", pod.Name, pod.Status.Phase)
allRunning = false
break
}
Expand Down Expand Up @@ -198,7 +198,7 @@ func (c K8Client) AwaitPodReadiness(podName string, timeout time.Duration) error
pod, err := c.Clientset.CoreV1().Pods(c.GetCurrentNamespace()).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
LogVerbose("Failed to get pod %s. Will retry", pod.Name)
} else if pod.Status.ContainerStatuses[0].Ready { // assuming there is only one container
} else if pod.Status.Phase == v1.PodRunning && pod.Status.ContainerStatuses[0].Ready { // assuming there is only one container
return nil
} else {
LogVerbose("Pod %s is in phase %s, but not ready. Wait for some seconds", pod.Name, pod.Status.Phase)
Expand Down

0 comments on commit c82a71e

Please sign in to comment.