Skip to content

Commit

Permalink
add pod.Status.{Reason,Message} to PodNotAvailable error
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lahabana committed Jan 6, 2023
1 parent e63181e commit a735c77
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/k8s/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a735c77

Please sign in to comment.