tournesol-app / tournesol

Free and open source code of the https://tournesol.app platform. Meet the community on Discord https://discord.gg/WvcSG55Bf3
https://tournesol.app
Other
325 stars 47 forks source link

[infra] fix: automatically restart `tournesol-website-analytics` when the Docker config changes #1347

Closed GresilleSiffle closed 1 year ago

GresilleSiffle commented 1 year ago

only relevant if https://github.com/tournesol-app/tournesol/pull/1340 is merged


Context

When the Docker configuration file /etc/docker/daemon.json is updated, the containers of Plausible Analytics are not automatically removed and re-created. As a consequence, some configuration modifications like a change of the default logging driver won't automatically be effective after a deployment. A manual restart of tournesol-website-analytics with systemctl is required to apply the changes.

technical details

If following Ansible task updates the /etc/docker/daemon.json, a restart of the service should be triggered. Note that notifying a handler with only notify and listen won't work properly. The first time a VM is provisioned, the Plausible Analytics service doesn't exist when the following task is running. Triggering the restart of a non-existing service will make the deployment fail. The restart should be conditioned by the existence of the service.

- name: Copy the Docker settings
  template:
    src: daemon.json.j2
    dest: /etc/docker/daemon.json
    mode: 0644
  notify:
    - Restart Docker
GresilleSiffle commented 1 year ago

This problem is highly mitigated by https://github.com/tournesol-app/tournesol/pull/1340#discussion_r1115328243