From a735c7735bd581c7ba308a1e3251d14cd24b5fcc Mon Sep 17 00:00:00 2001 From: Charly Molter Date: Fri, 6 Jan 2023 09:43:35 +0100 Subject: [PATCH] add `pod.Status.{Reason,Message}` to `PodNotAvailable` error When writing tests using terratest it's useful to figure why a pod failed to start. For example we use heavily terratest in our e2e suite. Some tests are flaky for many possible reasons at the moment we have to switch to using: `WaitUntilPodAvailableE` and use the error to get the pod status. Signed-off-by: Charly Molter --- modules/k8s/errors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/k8s/errors.go b/modules/k8s/errors.go index c425bbc36..6bfa641a3 100644 --- a/modules/k8s/errors.go +++ b/modules/k8s/errors.go @@ -68,7 +68,7 @@ type PodNotAvailable struct { // Error is a simple function to return a formatted error message as a string func (err PodNotAvailable) Error() string { - return fmt.Sprintf("Pod %s is not available", err.pod.Name) + return fmt.Sprintf("Pod %s is not available, reason: %s, message: %s", err.pod.Name, err.pod.Status.Reason, err.pod.Status.Message) } // NewPodNotAvailableError returnes a PodNotAvailable struct when Kubernetes deems a pod is not available