Skip to content

Commit 86d4a6d

Browse files
committed
ceph_migrate refactor restart mgr handler as task to fix role usage
This is a follow-up to #1089. Previously, the 'restart mgr' operation was implemented as a handler. The previous handler approach caused unexpected behaviors, as handlers are only executed once at the end of the playbook, even if notified multiple times. Additionally, the last restart must call 'cephadm' directly on the compute node, not via the ceph_cli container on the controller node. This commit moves the restart logic inline, directly after host removal in the MON removal block. - The handler file (handlers/main.yml) is deleted. - The restart mgr command is now an explicit task, using 'cephadm shell -- ceph mgr fail' and running on a ComputeHCI node when available, to ensure manager failover is properly triggered. Signed-off-by: Roberto Alfieri <[email protected]>
1 parent 89f1ec7 commit 86d4a6d

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-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: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,17 @@
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)
127126
ansible.builtin.debug:
128127
msg: "{{ spc }}"
129128

129+
- name: restart mgr
130+
become: true
131+
ansible.builtin.command:
132+
"{{ ceph_cli }} mgr fail"
133+
130134
# Check if a mon exists in the target node and remove it
131135
- name: MON - Get tmp mon
132136
ansible.builtin.command: "{{ ceph_cli }} orch ps --daemon_type mon --daemon_id {{ daemon_id }} -f json"
@@ -143,7 +147,11 @@
143147
delay: "{{ ceph_retry_delay }}"
144148
loop_control:
145149
label: "MON - Get tmp mon"
146-
notify: restart mgr
150+
151+
- name: restart mgr
152+
become: true
153+
ansible.builtin.command:
154+
"{{ ceph_cli }} mgr fail"
147155

148156
- name: MON - Wait for the current mon to be deleted
149157
ansible.builtin.pause:
@@ -157,7 +165,11 @@
157165
- name: MON - Redeploy mon on {{ target_node }}
158166
ansible.builtin.command:
159167
"{{ ceph_cli }} orch daemon add mon {{ target_node }}:{{ mon_ipaddr }}"
160-
notify: restart mgr
168+
169+
- name: restart mgr
170+
become: true
171+
ansible.builtin.command:
172+
"{{ ceph_cli }} mgr fail"
161173

162174
- name: MON - Wait for the spec to be updated
163175
ansible.builtin.pause:
@@ -197,7 +209,11 @@
197209
CEPH_CONTAINER_IMAGE: "{{ ceph_container }}"
198210
CEPH_CONTAINER_BINARY: "{{ ceph_container_cli }}"
199211
CEPH_CONF: "{{ ceph_config_tmp_client_home }}"
200-
notify: restart mgr
212+
213+
- name: restart mgr
214+
become: true
215+
ansible.builtin.command:
216+
"{{ ceph_cli }} mgr fail"
201217

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

0 commit comments

Comments
 (0)