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: Iddea0c21da194ef7cbe781d4fc4ad932f6fc2c14
Closes-Bug: #1889279
(cherry picked from commit 436671832b)
This commit is contained in:
Francesco Pantano 2020-07-28 18:44:54 +02:00
parent 1daaefffb5
commit 5dcaa10e89
1 changed files with 3 additions and 1 deletions

View File

@ -63,9 +63,11 @@
- when:
- osd_percentage_min|default(0) > 0
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
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
become: true