From 86b7137b2705adf5529d6241141b49336c10b91c Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Wed, 9 Oct 2019 16:50:09 -0400 Subject: [PATCH] ceph-iscsi: notify rbd target services When the iscsi gateway or the ceph configuration file change then we need to notify the rbd target api/gw services to be restarted. This patch also merges the rbd-target-api and rbd-target-gw handler into a single file and listen. Signed-off-by: Dimitri Savineau (cherry picked from commit bc701860d541b9f752d0f8cfcbed43979aafb70e) --- roles/ceph-config/tasks/main.yml | 2 ++ roles/ceph-handler/handlers/main.yml | 11 +++----- ..._api.yml => handler_rbd_target_api_gw.yml} | 26 +++++++++++++++++++ .../tasks/handler_rbd_target_gw.yml | 26 ------------------- roles/ceph-iscsi-gw/tasks/common.yml | 1 + roles/ceph-iscsi-gw/tasks/systemd.yml | 4 ++- 6 files changed, 35 insertions(+), 35 deletions(-) rename roles/ceph-handler/tasks/{handler_rbd_target_api.yml => handler_rbd_target_api_gw.yml} (50%) delete mode 100644 roles/ceph-handler/tasks/handler_rbd_target_gw.yml diff --git a/roles/ceph-config/tasks/main.yml b/roles/ceph-config/tasks/main.yml index f6bbd7462..a590b86d2 100644 --- a/roles/ceph-config/tasks/main.yml +++ b/roles/ceph-config/tasks/main.yml @@ -91,6 +91,7 @@ - restart ceph rgws - restart ceph mgrs - restart ceph rbdmirrors + - restart ceph rbd-target-api-gw - name: "ensure fetch directory exists" run_once: true @@ -149,3 +150,4 @@ - restart ceph rgws - restart ceph mgrs - restart ceph rbdmirrors + - restart ceph rbd-target-api-gw diff --git a/roles/ceph-handler/handlers/main.yml b/roles/ceph-handler/handlers/main.yml index 83809a294..65b0ba994 100644 --- a/roles/ceph-handler/handlers/main.yml +++ b/roles/ceph-handler/handlers/main.yml @@ -49,12 +49,7 @@ when: iscsi_gw_group_name in group_names listen: "restart ceph tcmu-runner" - - name: rbd-target-gw handler - include_tasks: handler_rbd_target_gw.yml + - name: rbd-target-api and rbd-target-gw handler + include_tasks: handler_rbd_target_api_gw.yml when: iscsi_gw_group_name in group_names - listen: "restart ceph rbd-target-gw" - - - name: rbd-target-api handler - include_tasks: handler_rbd_target_api.yml - when: iscsi_gw_group_name in group_names - listen: "restart ceph rbd-target-api" + listen: "restart ceph rbd-target-api-gw" diff --git a/roles/ceph-handler/tasks/handler_rbd_target_api.yml b/roles/ceph-handler/tasks/handler_rbd_target_api_gw.yml similarity index 50% rename from roles/ceph-handler/tasks/handler_rbd_target_api.yml rename to roles/ceph-handler/tasks/handler_rbd_target_api_gw.yml index 8843503d1..c8bfb12c2 100644 --- a/roles/ceph-handler/tasks/handler_rbd_target_api.yml +++ b/roles/ceph-handler/tasks/handler_rbd_target_api_gw.yml @@ -24,3 +24,29 @@ - name: set _rbd_target_api_handler_called after restart set_fact: _rbd_target_api_handler_called: False + +- name: set _rbd_target_gw_handler_called before restart + set_fact: + _rbd_target_gw_handler_called: True + +- name: copy rbd-target-gw restart script + template: + src: restart_rbd_target_gw.sh.j2 + dest: /tmp/restart_rbd_target_gw.sh + owner: root + group: root + mode: 0750 + +- name: restart rbd-target-gw + command: /usr/bin/env bash /tmp/restart_rbd_target_gw.sh + when: + - ceph_rbd_target_gw_stat.get('rc') == 0 + - hostvars[item]['_rbd_target_gw_handler_called'] | default(False) | bool + - ceph_rbd_target_gw_stat.get('stdout_lines', [])|length != 0 + with_items: "{{ groups[iscsi_gw_group_name] }}" + delegate_to: "{{ item }}" + run_once: True + +- name: set _rbd_target_gw_handler_called after restart + set_fact: + _rbd_target_gw_handler_called: False diff --git a/roles/ceph-handler/tasks/handler_rbd_target_gw.yml b/roles/ceph-handler/tasks/handler_rbd_target_gw.yml deleted file mode 100644 index 17cbb0939..000000000 --- a/roles/ceph-handler/tasks/handler_rbd_target_gw.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: set _rbd_target_gw_handler_called before restart - set_fact: - _rbd_target_gw_handler_called: True - -- name: copy rbd-target-gw restart script - template: - src: restart_rbd_target_gw.sh.j2 - dest: /tmp/restart_rbd_target_gw.sh - owner: root - group: root - mode: 0750 - -- name: restart rbd-target-gw - command: /usr/bin/env bash /tmp/restart_rbd_target_gw.sh - when: - - ceph_rbd_target_gw_stat.get('rc') == 0 - - hostvars[item]['_rbd_target_gw_handler_called'] | default(False) | bool - - ceph_rbd_target_gw_stat.get('stdout_lines', [])|length != 0 - with_items: "{{ groups[iscsi_gw_group_name] }}" - delegate_to: "{{ item }}" - run_once: True - -- name: set _rbd_target_gw_handler_called after restart - set_fact: - _rbd_target_gw_handler_called: False diff --git a/roles/ceph-iscsi-gw/tasks/common.yml b/roles/ceph-iscsi-gw/tasks/common.yml index c7e8d8cdf..93c8ba9b0 100644 --- a/roles/ceph-iscsi-gw/tasks/common.yml +++ b/roles/ceph-iscsi-gw/tasks/common.yml @@ -28,6 +28,7 @@ dest: /etc/ceph/iscsi-gateway.cfg config_type: ini config_overrides: '{{ iscsi_conf_overrides }}' + notify: restart ceph rbd-target-api-gw - name: set_fact container_exec_cmd set_fact: diff --git a/roles/ceph-iscsi-gw/tasks/systemd.yml b/roles/ceph-iscsi-gw/tasks/systemd.yml index 6768716b0..359342260 100644 --- a/roles/ceph-iscsi-gw/tasks/systemd.yml +++ b/roles/ceph-iscsi-gw/tasks/systemd.yml @@ -11,4 +11,6 @@ - tcmu-runner - rbd-target-gw - rbd-target-api - notify: restart ceph {{ item }} + notify: + - restart ceph tcmu-runner + - restart ceph rbd-target-api-gw