From 47ebd025dfdd0cdc1ee7ce4c7a1896caadaf768b Mon Sep 17 00:00:00 2001 From: Prajyot Parab <42934355+Prajyot-Parab@users.noreply.github.com> Date: Thu, 28 Jan 2021 19:30:31 +0530 Subject: [PATCH] pre-upgrade health checks (#98) Fixes: #97 Signed-off-by: Prajyot Parab --- playbooks/roles/ocp-upgrade/tasks/main.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/playbooks/roles/ocp-upgrade/tasks/main.yaml b/playbooks/roles/ocp-upgrade/tasks/main.yaml index c9438bf6..391d994f 100644 --- a/playbooks/roles/ocp-upgrade/tasks/main.yaml +++ b/playbooks/roles/ocp-upgrade/tasks/main.yaml @@ -1,5 +1,23 @@ --- +- name: Fetch cluster operators details + shell: "oc get co" + register: oplog + until: "'AVAILABLE' in oplog.stdout" + retries: 3 + delay: 3 + +- name: Process cluster operators details + shell: | + echo "{{ oplog.stdout }}" | awk '/PROGRESSING/,EOF {print $4}' | grep 'True' | wc -l + echo "{{ oplog.stdout }}" | awk '/DEGRADED/,EOF {print $5}' | grep 'True' | wc -l + register: opcount + +- name: Fail upgrade process incase cluster state is unhealthy + fail: + msg: The current cluster state is unhealthy, upgrading it is not recommended. Please run 'oc get co' command for more details or try upgrade after sometime. + when: opcount.stdout_lines[0]|int > 0 or opcount.stdout_lines[1]|int > 0 + - name: Upgrade ocp to a stable version block: - name: Set upgrade channel