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>
129 lines
4.2 KiB
YAML
129 lines
4.2 KiB
YAML
---
|
|
- name: Create cell0 mappings
|
|
vars:
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
command: bash -c 'sudo -E kolla_set_configs && nova-manage cell_v2 map_cell0'
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
image: "{{ nova_api.image }}"
|
|
labels:
|
|
BOOTSTRAP:
|
|
name: "create_cell0_nova"
|
|
restart_policy: no
|
|
volumes: "{{ nova_api.volumes|reject('equalto', '')|list }}"
|
|
register: map_cell0
|
|
changed_when:
|
|
- map_cell0 is success
|
|
- '"Cell0 is already setup" not in map_cell0.stdout'
|
|
failed_when:
|
|
- map_cell0.rc != 0
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
|
|
- include_tasks: bootstrap_service.yml
|
|
when: map_cell0.changed
|
|
|
|
- name: Get list of existing cells
|
|
vars:
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
command: bash -c 'sudo -E kolla_set_configs && nova-manage cell_v2 list_cells --verbose'
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
image: "{{ nova_api.image }}"
|
|
labels:
|
|
BOOTSTRAP:
|
|
name: "list_cells_nova"
|
|
restart_policy: no
|
|
volumes: "{{ nova_api.volumes|reject('equalto', '')|list }}"
|
|
register: existing_cells_list
|
|
changed_when: false
|
|
failed_when:
|
|
- existing_cells_list.rc != 0
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
|
|
- name: Check if a base cell already exists
|
|
vars:
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
# We match lines containing a UUID in a column (except the one used by
|
|
# cell0), followed by two other columns, the first containing the transport
|
|
# URL and the second the database connection. For example:
|
|
#
|
|
# | None | 68a3f49e-27ec-422f-9e2e-2a4e5dc8291b | rabbit://openstack:password@1.2.3.4:5672 | mysql+pymysql://nova:password@1.2.3.4:3306/nova |
|
|
#
|
|
# NOTE(priteau): regexp doesn't support passwords containing spaces
|
|
regexp: '\| +(?!00000000-0000-0000-0000-000000000000)([0-9a-f\-]+) +\| +([^ ]+) +\| +([^ ]+) +\|$'
|
|
set_fact:
|
|
existing_cells: "{{ existing_cells_list.stdout | regex_findall(regexp, multiline=True) }}"
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
|
|
- name: Create base cell for legacy instances
|
|
vars:
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
command: bash -c 'sudo -E kolla_set_configs && nova-manage cell_v2 create_cell'
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
image: "{{ nova_api.image }}"
|
|
labels:
|
|
BOOTSTRAP:
|
|
name: "create_cell_nova"
|
|
restart_policy: no
|
|
volumes: "{{ nova_api.volumes|reject('equalto', '')|list }}"
|
|
register: base_cell
|
|
changed_when:
|
|
- base_cell is success
|
|
failed_when:
|
|
- base_cell.rc != 0
|
|
- '"already exists" not in base_cell.stdout'
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
when: existing_cells | length == 0
|
|
|
|
- name: Update base cell for legacy instances
|
|
vars:
|
|
connection_url: "mysql+pymysql://{{ nova_database_user }}:{{ nova_database_password }}@{{ nova_database_address }}/{{ nova_database_name }}"
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
become: true
|
|
kolla_docker:
|
|
action: "start_container"
|
|
command: "bash -c 'sudo -E kolla_set_configs && nova-manage cell_v2 update_cell --cell_uuid {{ existing_cells[0][0] }}'"
|
|
common_options: "{{ docker_common_options }}"
|
|
detach: False
|
|
image: "{{ nova_api.image }}"
|
|
labels:
|
|
BOOTSTRAP:
|
|
name: "create_cell_nova"
|
|
restart_policy: no
|
|
volumes: "{{ nova_api.volumes|reject('equalto', '')|list }}"
|
|
register: base_cell
|
|
changed_when:
|
|
- base_cell is success
|
|
failed_when:
|
|
- base_cell.rc != 0
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
when:
|
|
- existing_cells | length == 1
|
|
- existing_cells[0][1] != rpc_transport_url or existing_cells[0][2] != connection_url
|
|
|
|
- name: Print warning if a duplicate cell is detected
|
|
vars:
|
|
nova_api: "{{ nova_services['nova-api'] }}"
|
|
fail:
|
|
msg: Multiple base cells detected, manual cleanup with `nova-manage cell_v2` may be required.
|
|
ignore_errors: yes
|
|
run_once: True
|
|
delegate_to: "{{ groups[nova_api.group][0] }}"
|
|
when:
|
|
- existing_cells | length > 1
|