Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alloy: Use service reload instead of restart #219

Open
f9n opened this issue Jun 11, 2024 · 2 comments
Open

alloy: Use service reload instead of restart #219

f9n opened this issue Jun 11, 2024 · 2 comments

Comments

@f9n
Copy link

f9n commented Jun 11, 2024

When you change the configuration of the alloy service, ansible role restarts the service. So all the nodes of the cluster are down, they are replaying the wal files. Can we reload it when the configuration is changed?

# roles/alloy/tasks/configure.yml#L19
- name: Deploy alloy configuration file
  ansible.builtin.template:
    src: config.alloy.j2
    dest: "{{ config_dir }}/{{ config_file }}"
    owner: "{{ service_user }}"
    group: "{{ service_group }}"
    mode: '0644'
  notify: Reload alloy
  become: true

# roles/alloy/handlers/main.yml#L7 Add new handler
- name: Check if alloy service is active
  ansible.builtin.shell: systemctl is-active alloy
  register: alloy_service_status
  ignore_errors: true
  listen: "Reload alloy"

- name: Restart alloy service if not active
  ansible.builtin.service:
    name: alloy
    state: restarted
  when: alloy_service_status.stdout != "active"
  listen: "Reload alloy"

- name: Reload alloy service if active
  ansible.builtin.service:
    name: alloy
    state: reloaded
  when: alloy_service_status.stdout == "active"
  listen: "Reload alloy"

- name: Check alloy is started properly
  ansible.builtin.include_tasks: ga-started.yml
  listen: "Reload alloy"

If it is convenient for you, we can create a pull request for the above changes.
cc: @emre-23 @acciorg

@ishanjainn
Copy link
Member

Thanks @f9n
Yeah that makes sense and yeah definitely put a PR

@voidquark
Copy link
Collaborator

If you'd like to implement this, I believe it should be sufficient to update the template task to trigger a reload instead of a restart and create a new handler for the reload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants