Make Get OSD stat percentage compatible with jq < 1.5

On upgrades we're using validations (from train) against controller that
are still on queens. On queens jq package is <1.5 and the "try" keyword
is not available.
This purpose of this change is to fix this validations getting rid of
"try-catch" in favour of "if-else" which works for 1.3+ < jq < 1.5.

Change-Id: Id16ccf69888ceb03cc33e0627de5270f9c8f4b95
Closes-Bug: #1889279
This commit is contained in:
Francesco Pantano 2020-07-28 18:44:54 +02:00
parent 605dae9b80
commit 6c19d1bcdf
No known key found for this signature in database
GPG Key ID: 799868C47301D458
1 changed files with 3 additions and 1 deletions

View File

@ -63,9 +63,11 @@
- when: - when:
- osd_percentage_min|default(0) > 0 - osd_percentage_min|default(0) > 0
block: block:
# 1.3+ <= jq <= 1.5 doesn't support try-catch: we rely on if - then -else approach to check if ceph has .osdmap layout
- name: set jq osd percentage filter - name: set jq osd percentage filter
set_fact: set_fact:
jq_osd_percentage_filter: '( (try .osdmap.num_in_osds + try .num_in_osds) / (try .osdmap.num_osds + try .num_osds)) * 100' jq_osd_percentage_filter: '(if .osdmap != null then { osds: (.osdmap.num_in_osds / .osdmap.num_osds * 100) }
else { osds: (.num_in_osds / .num_osds * 100) } end) | .osds'
- name: Get OSD stat percentage - name: Get OSD stat percentage
become: true become: true