kolla-ansible/ansible/roles/monasca/tasks/upgrade.yml
Doug Szumski 2c730590d7 Improve Grafana DB bootstrap
This fixes an issue where multiple Grafana instances would race
to bootstrap the Grafana DB. The following changes are made:

- Only start additional Grafana instances after the DB has been
  configured.

- During upgrade, don't allow old instances to run with an
  upgraded DB schema.

Change-Id: I3e0e077ba6a6f43667df042eb593107418a06c39
Closes-Bug: #1888681
2020-07-27 08:23:05 +00:00

40 lines
1.2 KiB
YAML

---
- name: Checking if Monasca Grafana container needs upgrading
vars:
service_name: "monasca-grafana"
service: "{{ monasca_services[service_name] }}"
become: true
kolla_docker:
action: "compare_image"
common_options: "{{ docker_common_options }}"
name: "{{ project_name }}"
image: "{{ monasca_grafana_image_full }}"
when: inventory_hostname in groups['monasca-grafana']
register: monasca_grafana_differs
- include_tasks: config.yml
# NOTE(dszumski): We don't want old Grafana instances running after
# a new instance has updated the DB schema. Since the first instance
# is upgraded first, we stop all the other ones.
- name: Stopping all Monasca Grafana instances but the first node
vars:
service_name: "monasca-grafana"
service: "{{ monasca_services[service_name] }}"
become: true
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
when:
- inventory_hostname != groups['monasca-grafana']|first
- monasca_grafana_differs['result']
- include_tasks: register.yml
when: inventory_hostname in groups['monasca-api']
- include_tasks: bootstrap_service.yml
- name: Flush handlers
meta: flush_handlers