Skip to content

Commit

Permalink
Skip service reload when restart already triggered
Browse files Browse the repository at this point in the history
Upon changes, some tasks will trigger the reload handler while others
will trigger the restart handler. During initial installation of Slurm
with the role, this can lead to some race condition where reload and
restart will execute too closely one from the other, which can trigger a
failure of the second service.

When a restart handler is notified, there should be no need to trigger
the reload as well. Move the restart handlers before the reload handlers
to make sure those are executed first. Register their result in a
variable. Test if the variable is defined in the reload handler (which
means that the restart handler was executed).

Also remove one of the 'Reload slurmdbd' handler which was defined
twice.
  • Loading branch information
btravouillon committed Sep 4, 2024
1 parent b1f1354 commit a59dd8b
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
name: munge
state: restarted

- name: Reload slurmdbd
ansible.builtin.service:
name: "{{ slurmdbd_service_name }}"
state: reloaded
when: "(slurm_start_services | bool) and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

- name: Restart slurmdbd
ansible.builtin.systemd:
name: "{{ slurmdbd_service_name }}"
Expand All @@ -18,18 +12,16 @@
enabled: yes
daemon_reload: yes
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"
register: slurmdbd_restart

- name: Restart slurmdbd
- name: Reload slurmdbd
ansible.builtin.service:
name: "{{ slurmdbd_service_name }}"
state: restarted
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

- name: Reload slurmctld
ansible.builtin.service:
name: "{{ slurmctld_service_name }}"
state: reloaded
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"
when:
- slurm_start_services | bool
- ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)
- slurmdbd_restart is not defined

- name: Restart slurmctld
ansible.builtin.systemd:
Expand All @@ -39,15 +31,29 @@
enabled: yes
daemon_reload: yes
when: "(slurm_start_services | bool) and ('slurmservers' in group_names or 'controller' in slurm_roles)"
register: slurmctld_restart

- name: Reload slurmd
- name: Reload slurmctld
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
name: "{{ slurmctld_service_name }}"
state: reloaded
when: "(slurm_start_services | bool) and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when:
- slurm_start_services | bool
- ('slurmservers' in group_names or 'controller' in slurm_roles)
- slurmctld_restart is not defined

- name: Restart slurmd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
state: restarted
when: "(slurm_start_services | bool) and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
register: slurmd_restart

- name: Reload slurmd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
state: reloaded
when:
- slurm_start_services | bool
- ('slurmexechosts' in group_names or 'exec' in slurm_roles)
- slurmd_restart is not defined

0 comments on commit a59dd8b

Please sign in to comment.