Description
What would you like to be added?
Tests that use wait.PollImmediate
(directly or indirectly, as in
kubernetes/test/e2e/framework/pod/wait.go
Lines 386 to 426 in ed07515
/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/storage/pvc_protection.go:72
Nov 13 14:20:10.683: While creating pod that uses the PVC or waiting for the Pod to become Running
Unexpected error:
<*errors.errorString | 0xc003d86070>: {
s: "pod \"pvc-tester-w2jjx\" is not Running: timed out waiting for the condition",
}
pod "pvc-tester-w2jjx" is not Running: timed out waiting for the condition
occurred
/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/storage/pvc_protection.go:96
This is actually one of the better examples. In other cases the only failure message is "timed out waiting for the condition" without any indication what the condition was expected to be. Even in this example it is not clear what the state of the pod was in the end. Were there some events for the pod? What's its status?
Example from 2025, after conversion to wait.PollUntilContextTimeout
:
[FAILED] client rate limiter Wait returned an error: context deadline exceeded
In [It] at: k8s.io/kubernetes/test/e2e/apimachinery/resource_quota.go:544
A better way to write such tests is with gomega.Eventually
and a custom matcher. Eventually
handles the polling. In case of a failure, the matcher is called to produce a failure report which then can include arbitrary additional information that currently developers have to start hunting for in log files, if they can be found there at all.
Metrics testing is another example where some data is checked against certain expectations. Because the data is never logged, it is impossible to tell after a failure what went wrong.
Why is this needed?
Easier debugging after an E2E test failure.