Always log ONAP pod status to console
It is important to log the status of ONAP pods to console
even if the deployment fails in order to see what worked
and what did not.
installer-type: kubespray
deploy-scenario: k8-calico-nofeature
Change-Id: I3a5083914eb3f57ad9366ac0dcb2a77a8691bc65
diff --git a/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/files/log-onap-status.sh b/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/files/log-onap-status.sh
new file mode 100755
index 0000000..3583a01
--- /dev/null
+++ b/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/files/log-onap-status.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+cat << EOF
+---------------------------------------------
+ONAP pods in Create or ImagePullBackOff state
+---------------------------------------------
+$(kubectl get pod -n onap | grep -i 'creating\|ImagePullBackOff')
+
+
+---------------------------------------------
+ONAP pods in Init state
+---------------------------------------------
+$(kubectl get pod -n onap | grep Init | grep -v Error)
+
+
+---------------------------------------------
+ONAP pods in Error or CrashLoopBackOff state
+---------------------------------------------
+$(kubectl get pod -n onap | grep 'Crash\|Error')
+
+
+---------------------------------------------
+Summary
+---------------------------------------------
+Creating/ImagePullBackOff : $(kubectl get pod -n onap | grep -i 'creating\|ImagePullBackOff' | wc -l) pods
+Init : $(kubectl get pod -n onap | grep Init | grep -v Error | wc -l) pods
+Error/CrashLoopBackOff : $(kubectl get pod -n onap | grep 'Error\|Crash' | wc -l) pods
+Terminating : $(kubectl get pod -n onap | grep -i terminating | wc -l) pods
+Running/Completed : $(kubectl get pod -n onap | grep -i 'running\|completed' | wc -l) pods
+Total : $(kubectl get pod -n onap | grep -v RESTART | wc -l) pods
+---------------------------------------------
+EOF
diff --git a/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/tasks/post-deployment/install-onap.yml b/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/tasks/post-deployment/install-onap.yml
index f6b41b1..25bef98 100644
--- a/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/tasks/post-deployment/install-onap.yml
+++ b/scenarios/onap-nofeature-noha/kubespray/role/onap-nofeature-noha/tasks/post-deployment/install-onap.yml
@@ -101,26 +101,35 @@
delay: 10
# wait 75 minutes for all containers to be initialized
-- name: Wait for all containers to be initialized
- shell:
- "kubectl get po -n onap | \
- grep Init | grep -v Error | wc -l"
- register: kube
- changed_when:
- kube.stdout == '0'
- until:
- kube.stdout == '0'
- retries: 450
- delay: 10
+- block:
+ - name: Wait for all containers to be initialized
+ shell:
+ "kubectl get po -n onap | \
+ grep Init | grep -v Error | wc -l"
+ register: kube
+ changed_when:
+ kube.stdout == '0'
+ until:
+ kube.stdout == '0'
+ retries: 450
+ delay: 10
+ always:
+ - name: Get POD status
+ shell:
+ "kubectl get po -n onap"
+ changed_when: "false"
+ register: kube
-- name: Get POD status
- shell:
- "kubectl get po -n onap"
- changed_when: "false"
- register: kube
+ - name: Log POD status to console
+ debug:
+ msg: "{{ kube.stdout_lines }}"
-- name: Log POD status to console
- debug:
- msg: "{{ kube.stdout_lines }}"
+ - name: Get summary of ONAP deployment
+ script: log-onap-status.sh
+ register: onap_status
+
+ - name: Log ONAP status to console
+ debug:
+ msg: "{{ onap_status.stdout_lines }}"
# vim: set ts=2 sw=2 expandtab: