Skip to content

Commit efc8498

Browse files
slyt3dmjbjhrozek
authored
Fix logic bug in WaitForPodsReady that incorrectly reports pods as ready (#2898)
Co-authored-by: Don Browne <dmjb@users.noreply.github.com> Co-authored-by: Jakub Hrozek <jakub.hrozek@posteo.se>
1 parent 2b6a4a7 commit efc8498

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/e2e/thv-operator/virtualmcp/helpers.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,26 @@ func WaitForPodsReady(ctx context.Context, c client.Client, namespace string, la
181181
return fmt.Errorf("pod %s is in phase %s", pod.Name, pod.Status.Phase)
182182
}
183183

184+
containerReady := false
185+
podReady := false
186+
184187
for _, condition := range pod.Status.Conditions {
185-
if condition.Type == corev1.ContainersReady && condition.Status != corev1.ConditionTrue {
186-
return fmt.Errorf("pod %s containers not ready", pod.Name)
188+
if condition.Type == corev1.ContainersReady {
189+
containerReady = condition.Status == corev1.ConditionTrue
190+
}
191+
192+
if condition.Type == corev1.PodReady {
193+
podReady = condition.Status == corev1.ConditionTrue
187194
}
188195
}
196+
197+
if !containerReady {
198+
return fmt.Errorf("pod %s containers not ready", pod.Name)
199+
}
200+
201+
if !podReady {
202+
return fmt.Errorf("pod %s not ready", pod.Name)
203+
}
189204
}
190205
return nil
191206
}, timeout, 5*time.Second).Should(gomega.Succeed())

0 commit comments

Comments
 (0)