Skip to content

Commit

Permalink
PMM-12530 use a different become method for supervisorctl
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Dec 12, 2023
1 parent c9d2b83 commit dbfa806
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
13 changes: 9 additions & 4 deletions build/ansible/pmm/post-build-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@
- name: See which service configs changed
debug: var=reread_result.stdout_lines

- name: Stop pmm-managed before deleting the database EL9
- name: Stop pmm-managed before deleting the database
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
supervisorctl:
name: pmm-managed
state: stopped
become: true
become_user: pmm
become_method: su

- name: Remove pmm-managed database EL9
- name: Remove pmm-managed database
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
Expand Down Expand Up @@ -123,8 +126,10 @@
path: /var/cache/dnf

- name: Cleanup build logs and data
file: path={{ item }} state=absent
with_items:
file:
path: "{{ item }}"
state: absent
loop:
- /srv/logs
- /tmp/RPMS
- /var/log/dnf.log
Expand Down
2 changes: 1 addition & 1 deletion build/ansible/roles/pmm-images/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
include_role:
name: supervisord-init

- name: PMM | Enable repo for pmm-client
- name: Enable repo for pmm-client
command: percona-release enable {{ pmm_client_repos }}

- name: Install pmm-client
Expand Down
2 changes: 2 additions & 0 deletions build/docker/server/Dockerfile.el9
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ RUN ansible-playbook -vvv -i 'localhost,' -c local /opt/ansible/pmm-docker/main.
&& ansible-playbook -vvv -i 'localhost,' -c local /opt/ansible/pmm/post-build-actions.yml

COPY entrypoint.sh /opt/entrypoint.sh

HEALTHCHECK --interval=3s --timeout=2s --start-period=10s --retries=3 CMD curl -f http://127.0.0.1:8080/v1/readyz || exit 1

CMD ["/opt/entrypoint.sh"]
14 changes: 6 additions & 8 deletions update/ansible/playbook/tasks/roles/dashboards/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
depth: 2
file_type: directory

- name: Delete redundant dist folders
- name: Delete older plugins
file:
path: "/srv/grafana/plugins/{{ item['path'].split('/')[-1] }}"
state: absent
Expand All @@ -26,14 +26,12 @@
mode: 0775
recurse: yes

- name: Restart grafana with new plugins EL9
# TODO: fix the race condition.
- name: Restart grafana with new plugins
supervisorctl:
name: grafana
state: restarted
become: true
when:
- ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux'
- ansible_distribution_major_version == '9'
ignore_errors: true
# TODO: fix the race condition.
# We generate grafana supervisor config in pmm-managed and it may not exist at this stage
become_user: pmm
become_method: su
# ignore_errors: true
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- pmm-agent
- postgresql
become: true
become_user: pmm
become_method: su

- name: Run Postgres database without supervisor
command: /usr/pgsql-14/bin/pg_ctl start -D /srv/postgres14 -o "-c logging_collector=off"
Expand Down Expand Up @@ -63,6 +65,8 @@
- postgresql
- pmm-managed
- pmm-agent
become: true
become: true
become_user: pmm
become_method: su

when: is_supervisor_running
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- pmm-agent
- postgresql
become: true
become_user: pmm
become_method: su

- name: Run Postgres database without supervisor
command: /usr/pgsql-14/bin/pg_ctl start -D /srv/postgres
Expand Down Expand Up @@ -68,6 +70,9 @@
- postgresql
- pmm-managed
- pmm-agent
become: true
become: true
become_user: pmm
become_method: su


when: is_supervisor_running
10 changes: 9 additions & 1 deletion update/ansible/playbook/tasks/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
path: /run/supervisor/supervisor.sock
register: is_supervisor_running

- name: Start supervisord for docker
# During build time, this will be the first start of supervisord.
- name: Start supervisord
when:
- not is_supervisor_running.stat.exists
shell: supervisord -c /etc/supervisord.conf &
Expand All @@ -70,6 +71,9 @@
# why we do reread + stop/remove/add instead of using supervisorctl Ansible module.
- name: Reread supervisord configuration
command: supervisorctl reread
become: true
become_user: pmm
become_method: su
register: reread_result
changed_when: "'No config updates to processes' not in reread_result.stdout"

Expand All @@ -79,6 +83,8 @@
- name: Restart pmm-managed
command: "supervisorctl {{ item }} pmm-managed"
become: true
become_user: pmm
become_method: su
loop:
- stop
- remove
Expand All @@ -102,6 +108,8 @@
- name: Restart services
command: supervisorctl {{ item.1 }} {{ item.0 }}
become: true
become_user: pmm
become_method: su
changed_when: true
with_nested:
- - nginx
Expand Down

0 comments on commit dbfa806

Please sign in to comment.