From 6c19d1bcdfc67ae3894959441684e62221ef620f Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Tue, 28 Jul 2020 18:44:54 +0200 Subject: [PATCH] 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 --- roles/ceph/tasks/ceph-health.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/ceph/tasks/ceph-health.yaml b/roles/ceph/tasks/ceph-health.yaml index 28b903f82..641434b06 100644 --- a/roles/ceph/tasks/ceph-health.yaml +++ b/roles/ceph/tasks/ceph-health.yaml @@ -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