6a737b1968
Docker has no restart policy named 'never'. It has 'no'. This has bitten us already (see [1]) and might bite us again whenever we want to change the restart policy to 'no'. This patch makes our docker integration honor all valid restart policies and only valid restart policies. All relevant docker restart policy usages are patched as well. I added some FIXMEs around which are relevant to kolla-ansible docker integration. They are not fixed in here to not alter behavior. [1] https://review.opendev.org/667363 Change-Id: I1c9764fb9bbda08a71186091aced67433ad4e3d6 Signed-off-by: Radosław Piliszek <radoslaw.piliszek@gmail.com>
194 lines
5.5 KiB
YAML
194 lines
5.5 KiB
YAML
---
|
|
- name: Starting first MariaDB container
|
|
vars:
|
|
service_name: "mariadb"
|
|
service: "{{ mariadb_services[service_name] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
common_options: "{{ docker_common_options }}"
|
|
environment:
|
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
|
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
|
|
image: "{{ service.image }}"
|
|
labels:
|
|
BOOTSTRAP:
|
|
name: "{{ service.container_name }}"
|
|
restart_policy: no
|
|
volumes: "{{ service.volumes }}"
|
|
dimensions: "{{ service.dimensions }}"
|
|
when:
|
|
- bootstrap_host is defined
|
|
- bootstrap_host == inventory_hostname
|
|
listen: Bootstrap MariaDB cluster
|
|
notify:
|
|
- restart mariadb
|
|
|
|
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
|
|
# https://github.com/ansible/ansible-modules-core/issues/2788
|
|
- name: wait first mariadb container
|
|
wait_for:
|
|
host: "{{ api_interface_address }}"
|
|
port: "{{ mariadb_port }}"
|
|
connect_timeout: 1
|
|
timeout: 60
|
|
search_regex: "MariaDB"
|
|
register: check_mariadb_port
|
|
until: check_mariadb_port is success
|
|
retries: 10
|
|
delay: 6
|
|
when:
|
|
- bootstrap_host is defined
|
|
- bootstrap_host == inventory_hostname
|
|
listen: Bootstrap MariaDB cluster
|
|
|
|
- name: Wait for MariaDB to become operational
|
|
become: true
|
|
command: >-
|
|
docker exec {{ mariadb_service.container_name }}
|
|
mysql -uroot -p{{ database_password }}
|
|
--silent --skip-column-names
|
|
-e 'SHOW STATUS LIKE "wsrep_evs_state"'
|
|
changed_when: false
|
|
register: result
|
|
until: '"OPERATIONAL" in result.stdout'
|
|
retries: 10
|
|
delay: 6
|
|
no_log: true
|
|
when:
|
|
- bootstrap_host is defined
|
|
- bootstrap_host == inventory_hostname
|
|
listen: Bootstrap MariaDB cluster
|
|
|
|
- name: restart slave mariadb
|
|
vars:
|
|
service_name: "mariadb"
|
|
service: "{{ mariadb_services[service_name] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "recreate_or_restart_container"
|
|
common_options: "{{ docker_common_options }}"
|
|
name: "{{ service.container_name }}"
|
|
image: "{{ service.image }}"
|
|
volumes: "{{ service.volumes }}"
|
|
dimensions: "{{ service.dimensions }}"
|
|
when:
|
|
- kolla_action != "config"
|
|
- inventory_hostname != master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|
|
|
|
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
|
|
# https://github.com/ansible/ansible-modules-core/issues/2788
|
|
- name: wait for slave mariadb
|
|
wait_for:
|
|
host: "{{ api_interface_address }}"
|
|
port: "{{ mariadb_port }}"
|
|
connect_timeout: 1
|
|
timeout: 60
|
|
search_regex: "MariaDB"
|
|
register: check_mariadb_port
|
|
until: check_mariadb_port is success
|
|
retries: 10
|
|
delay: 6
|
|
when:
|
|
- kolla_action != "config"
|
|
- inventory_hostname != master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|
|
|
|
- name: run upgrade on slave
|
|
vars:
|
|
service_name: "mariadb"
|
|
service: "{{ mariadb_services[service_name] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
dimensions: "{{ service.dimensions }}"
|
|
environment:
|
|
KOLLA_UPGRADE:
|
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
|
DB_HOST: "{{ api_interface_address }}"
|
|
DB_PORT: "{{ mariadb_port }}"
|
|
DB_ROOT_PASSWORD: "{{ database_password }}"
|
|
image: "{{ service.image }}"
|
|
labels:
|
|
UPGRADE:
|
|
name: "upgrade_mariadb"
|
|
restart_policy: no
|
|
volumes: "{{ service.volumes }}"
|
|
no_log: true
|
|
when:
|
|
- kolla_action == "upgrade"
|
|
- inventory_hostname != master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|
|
|
|
- name: restart master mariadb
|
|
vars:
|
|
service_name: "mariadb"
|
|
service: "{{ mariadb_services[service_name] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "recreate_or_restart_container"
|
|
common_options: "{{ docker_common_options }}"
|
|
name: "{{ service.container_name }}"
|
|
image: "{{ service.image }}"
|
|
volumes: "{{ service.volumes }}"
|
|
dimensions: "{{ service.dimensions }}"
|
|
when:
|
|
- kolla_action != "config"
|
|
- inventory_hostname == master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|
|
|
|
# TODO(jeffrey4l), remove the task check when the wait_for bug is fixed
|
|
# https://github.com/ansible/ansible-modules-core/issues/2788
|
|
- name: Waiting for master mariadb
|
|
wait_for:
|
|
host: "{{ api_interface_address }}"
|
|
port: "{{ mariadb_port }}"
|
|
connect_timeout: 1
|
|
timeout: 60
|
|
search_regex: "MariaDB"
|
|
register: check_mariadb_port
|
|
until: check_mariadb_port is success
|
|
retries: 10
|
|
delay: 6
|
|
when:
|
|
- kolla_action != "config"
|
|
- inventory_hostname == master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|
|
|
|
- name: run upgrade on master
|
|
vars:
|
|
service_name: "mariadb"
|
|
service: "{{ mariadb_services[service_name] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
dimensions: "{{ service.dimensions }}"
|
|
environment:
|
|
KOLLA_UPGRADE:
|
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
|
DB_HOST: "{{ api_interface_address }}"
|
|
DB_PORT: "{{ mariadb_port }}"
|
|
DB_ROOT_PASSWORD: "{{ database_password }}"
|
|
image: "{{ service.image }}"
|
|
labels:
|
|
UPGRADE:
|
|
name: "upgrade_mariadb"
|
|
restart_policy: no
|
|
volumes: "{{ service.volumes }}"
|
|
no_log: true
|
|
when:
|
|
- kolla_action == "upgrade"
|
|
- inventory_hostname == master_host
|
|
- not mariadb_recover | default(false)
|
|
listen: restart mariadb
|