From 78cc6794c3f13468588d66a72234b5288f94c002 Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Fri, 16 Sep 2022 03:46:03 +0000 Subject: [PATCH] Show details of problematic pod in the test To investigate a problem what some pod is not running easily, this adds the details of the pod when that happens. --- tests/testcases/020_check-pods-running.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/testcases/020_check-pods-running.yml b/tests/testcases/020_check-pods-running.yml index 46392d1d9..f42a0ee75 100644 --- a/tests/testcases/020_check-pods-running.yml +++ b/tests/testcases/020_check-pods-running.yml @@ -44,6 +44,18 @@ register: get_pods no_log: true - - debug: # noqa unnamed-task - msg: "{{ get_pods.stdout.split('\n') }}" - failed_when: not run_pods_log is success + - name: Show debugging information when some pods are not ready + when: not run_pods_log is success + block: + - debug: # noqa unnamed-task + msg: "{{ get_pods.stdout.split('\n') }}" + + - name: Get a not-running pod name + command: "{{ bin_dir }}/kubectl get pods --all-namespaces --field-selector=status.phase!=Running --output=jsonpath='{.items[0].metadata.namespace} {.items[0].metadata.name}'" + register: problematic_pod + no_log: true + failed_when: false + + - name: Describe the problematic pod + command: "{{ bin_dir }}/kubectl describe pod -n {{ problematic_pod.stdout }}" + failed_when: true