Skip to content

Commit

Permalink
pre-upgrade health checks (#98)
Browse files Browse the repository at this point in the history
Fixes: #97
Signed-off-by: Prajyot Parab <[email protected]>
  • Loading branch information
Prajyot-Parab authored Jan 28, 2021
1 parent cc5f5c9 commit fc74d7e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions playbooks/roles/ocp-upgrade/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit fc74d7e

Please sign in to comment.