From 3b0ee8359475aa49b7b78b134d167e1e030b74b4 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 28 Feb 2020 11:37:14 -0500 Subject: [PATCH] shrink-rbdmirror: fix presence after removal We should add retry/delay to check the presence of the rbdmirror daemon in the cluster status because the status takes some time to be updated. Also the metadata.hostname isn't a good key to check because it doesn't reflect the ansible_hostname fact. We should use metadata.id instead. Signed-off-by: Dimitri Savineau (cherry picked from commit d1316ce77b796ce969c2fd36c975baca3ffe0bc9) --- infrastructure-playbooks/shrink-rbdmirror.yml | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/infrastructure-playbooks/shrink-rbdmirror.yml b/infrastructure-playbooks/shrink-rbdmirror.yml index 15e488886..9b01a1e00 100644 --- a/infrastructure-playbooks/shrink-rbdmirror.yml +++ b/infrastructure-playbooks/shrink-rbdmirror.yml @@ -87,7 +87,7 @@ set_fact: rbdmirror_to_kill_gid: "{{ (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'][item]['gid'] }}" with_items: "{{ rbdmirror_gids }}" - when: (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'][item]['metadata']['hostname'] == rbdmirror_to_kill_hostname + when: (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'][item]['metadata']['id'] == rbdmirror_to_kill_hostname tasks: - name: stop rbdmirror service @@ -108,22 +108,15 @@ - name: get servicemap details command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} -s -f json" register: ceph_health - - - name: set_fact rbdmirror_gids - set_fact: - post_rbdmirror_gids: "{{ post_rbdmirror_gids | default([]) + [ item ] }}" - with_items: "{{ (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'].keys() | list }}" - when: + failed_when: - "'rbd-mirror' in (ceph_health.stdout | from_json)['servicemap']['services'].keys() | list" - - item != 'summary' + - rbdmirror_to_kill_gid in (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'].keys() | list + until: + - "'rbd-mirror' in (ceph_health.stdout | from_json)['servicemap']['services'].keys() | list" + - rbdmirror_to_kill_gid not in (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'].keys() | list + when: rbdmirror_to_kill_gid is defined + retries: 12 + delay: 10 - name: show ceph health command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s" - - - name: check presence of "{{ rbdmirror_to_kill_hostname }}" - fail: - msg: "{{ rbdmirror_to_kill_hostname }} still active!" - when: - - rbdmirror_to_kill_gid is defined - - post_rbdmirror_gids is defined - - rbdmirror_to_kill_gid in post_rbdmirror_gids