Skip to content

Commit fc7df71

Browse files
committed
ceph_migrate refactor restart mgr handler as task to fix role usage
This is a follow-up to #1089. Refactor `restart mgr` operation: remove handler, add explicit task. Previously, restarting the Ceph manager (`mgr`) used an Ansible handler, which delayed execution until the playbook's end. This caused issues for Ceph failover, as the action needed to occur immediately after MON host removal. Additionally, the handler restarted the manager from the controller node, but the correct approach is to run `cephadm` directly on a ComputeHCI node. This update removes the handler file and replaces it with an explicit task that runs right after the MON removal block in `drain.yaml`. The task directly runs `cephadm shell -- ceph mgr fail` on a ComputeHCI node when available, which ensures prompt and correct manager failover. - Deleted the now-unneeded `handlers/main.yml`. - Added a dedicated task to restart mgr after host removal, delegating to ComputeHCI if present. Signed-off-by: Roberto Alfieri <[email protected]>
1 parent 89f1ec7 commit fc7df71

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

tests/roles/ceph_migrate/handlers/main.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/roles/ceph_migrate/tasks/drain.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,12 @@
8181
when: lsh.stdout | from_json | community.general.json_query('[*].hostname') | length > 0
8282
ansible.builtin.command:
8383
"{{ ceph_cli }} orch host rm {{ cur_mon }} --force"
84-
notify: restart mgr
84+
85+
- name: restart mgr on compute
86+
become: true
87+
ansible.builtin.command:
88+
"cephadm shell -- ceph mgr fail"
89+
delegate_to: "{{ groups['ComputeHCI'][0] | default(inventory_hostname) }}"
90+
when:
91+
- groups['ComputeHCI'] is defined
92+
- groups['ComputeHCI'] | length > 0

tests/roles/ceph_migrate/tasks/mon.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
CEPH_CONTAINER_IMAGE: "{{ ceph_container }}"
121121
CEPH_CONTAINER_BINARY: "{{ ceph_container_cli }}"
122122
CEPH_CONF: "{{ ceph_config_tmp_client_home }}"
123-
notify: restart mgr
124123

125124
- name: Print the resulting spec
126125
when: debug | default(false)
@@ -143,7 +142,6 @@
143142
delay: "{{ ceph_retry_delay }}"
144143
loop_control:
145144
label: "MON - Get tmp mon"
146-
notify: restart mgr
147145

148146
- name: MON - Wait for the current mon to be deleted
149147
ansible.builtin.pause:
@@ -157,7 +155,6 @@
157155
- name: MON - Redeploy mon on {{ target_node }}
158156
ansible.builtin.command:
159157
"{{ ceph_cli }} orch daemon add mon {{ target_node }}:{{ mon_ipaddr }}"
160-
notify: restart mgr
161158

162159
- name: MON - Wait for the spec to be updated
163160
ansible.builtin.pause:
@@ -197,7 +194,6 @@
197194
CEPH_CONTAINER_IMAGE: "{{ ceph_container }}"
198195
CEPH_CONTAINER_BINARY: "{{ ceph_container_cli }}"
199196
CEPH_CONF: "{{ ceph_config_tmp_client_home }}"
200-
notify: restart mgr
201197

202198
# Wait for the redeploy to finish before moving to the next stage
203199
- name: MON - wait daemons

0 commit comments

Comments
 (0)