Optimize reconfiguration for octavia

Co-Authored-By: Mauricio Lima <mauriciolimab@gmail.com>
Change-Id: If6a0d935df9f8b84d7628b2c8753aa12627e2c8a
Partially-implements: blueprint better-reconfigure
This commit is contained in:
caoyuan 2017-01-22 22:28:19 +08:00
parent db20c0b20d
commit 517491a93a
9 changed files with 188 additions and 180 deletions

View File

@ -1,6 +1,45 @@
--- ---
project_name: "octavia" project_name: "octavia"
octavia_services:
octavia-api:
container_name: octavia_api
group: octavia-api
enabled: true
image: "{{ octavia_api_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-health-manager:
container_name: octavia_health_manager
group: octavia-health-manager
enabled: true
image: "{{ octavia_health_manager_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-health-manager/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-housekeeping:
container_name: octavia_housekeeping
group: octavia-housekeeping
enabled: true
image: "{{ octavia_housekeeping_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-housekeeping/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
octavia-worker:
container_name: octavia_worker
group: octavia-worker
enabled: true
image: "{{ octavia_worker_image_full }}"
volumes:
- "{{ node_config_directory }}/octavia-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
#################### ####################
# Database # Database
#################### ####################

View File

@ -0,0 +1,85 @@
---
- name: Restart octavia-api container
vars:
service_name: "octavia-api"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_api_container: "{{ check_octavia_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or octavia_conf.changed | bool
or octavia_api_container.changed | bool
- name: Restart octavia-health-manager container
vars:
service_name: "octavia-health-manager"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_health_manager_container: "{{ check_octavia_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or octavia_conf.changed | bool
or octavia_health_manager_container.changed | bool
- name: Restart octavia-housekeeping container
vars:
service_name: "octavia-housekeeping"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_housekeeping_container: "{{ check_octavia_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or octavia_conf.changed | bool
or octavia_housekeeping_container.changed | bool
- name: Restart octavia-worker container
vars:
service_name: "octavia-worker"
service: "{{ octavia_services[service_name] }}"
config_json: "{{ octavia_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_conf: "{{ octavia_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
octavia_worker_container: "{{ check_octavia_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or octavia_conf.changed | bool
or octavia_worker_certificate.changed | bool
or octavia_worker_container.changed | bool

View File

@ -1,5 +1,7 @@
--- ---
- name: Running Octavia bootstrap container - name: Running Octavia bootstrap container
vars:
octavia_api: "{{ octavia_services['octavia-api'] }}"
kolla_docker: kolla_docker:
action: "start_container" action: "start_container"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
@ -7,14 +9,11 @@
environment: environment:
KOLLA_BOOTSTRAP: KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ octavia_api_image_full }}" image: "{{ octavia_api.image }}"
labels: labels:
BOOTSTRAP: BOOTSTRAP:
name: "bootstrap_octavia" name: "bootstrap_octavia"
restart_policy: "never" restart_policy: "never"
volumes: volumes: "{{ octavia_api.volumes }}"
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True run_once: True
delegate_to: "{{ groups['octavia-api'][0] }}" delegate_to: "{{ groups[octavia_api.group][0] }}"

View File

@ -1,49 +1,76 @@
--- ---
- name: Ensuring config directories exist - name: Ensuring config directories exist
file: file:
path: "{{ node_config_directory }}/{{ item }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes recurse: yes
with_items: when:
- "octavia-api" - inventory_hostname in groups[item.value.group]
- "octavia-health-manager" - item.value.enabled | bool
- "octavia-housekeeping" with_dict: "{{ octavia_services }}"
- "octavia-worker"
- name: Copying over config.json files for services - name: Copying over config.json files for services
template: template:
src: "{{ item }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
with_items: register: octavia_config_jsons
- "octavia-api" when:
- "octavia-health-manager" - inventory_hostname in groups[item.value.group]
- "octavia-housekeeping" - item.value.enabled | bool
- "octavia-worker" with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over octavia.conf - name: Copying over octavia.conf
merge_configs: merge_configs:
vars: vars:
service_name: "{{ item }}" service_name: "{{ item.key }}"
sources: sources:
- "{{ role_path }}/templates/octavia.conf.j2" - "{{ role_path }}/templates/octavia.conf.j2"
- "{{ node_config_directory }}/config/global.conf" - "{{ node_config_directory }}/config/global.conf"
- "{{ node_config_directory }}/config/database.conf" - "{{ node_config_directory }}/config/database.conf"
- "{{ node_config_directory }}/config/messaging.conf" - "{{ node_config_directory }}/config/messaging.conf"
- "{{ node_config_directory }}/config/octavia.conf" - "{{ node_config_directory }}/config/octavia.conf"
- "{{ node_config_directory }}/config/octavia/{{ item }}.conf" - "{{ node_config_directory }}/config/octavia/{{ item.key }}.conf"
- "{{ node_config_directory }}/config/octavia/{{ inventory_hostname }}/octavia.conf" - "{{ node_config_directory }}/config/octavia/{{ inventory_hostname }}/octavia.conf"
dest: "{{ node_config_directory }}/{{ item }}/octavia.conf" dest: "{{ node_config_directory }}/{{ item.key }}/octavia.conf"
with_items: register: octavia_confs
- "octavia-api" when:
- "octavia-health-manager" - inventory_hostname in groups[item.value.group]
- "octavia-housekeeping" - item.value.enabled | bool
- "octavia-worker" with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying certificate files - name: Copying certificate files
vars:
service: "{{ octavia_services['octavia-worker'] }}"
copy: copy:
src: "{{ node_config_directory }}/config/octavia/{{ item }}" src: "{{ node_config_directory }}/config/octavia/{{ item }}"
dest: "{{ node_config_directory }}/octavia-worker/{{ item }}" dest: "{{ node_config_directory }}/octavia-worker/{{ item }}"
register: octavia_worker_certificate
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items: with_items:
- cakey.pem - cakey.pem
- ca_01.pem - ca_01.pem
- client.pem - client.pem
notify:
- Restart octavia-worker container
- name: Check octavia containers
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
volumes: "{{ item.value.volumes }}"
register: check_octavia_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ octavia_services }}"
notify:
- "Restart {{ item.key }} container"

View File

@ -11,8 +11,5 @@
- include: "bootstrap.yml" - include: "bootstrap.yml"
when: inventory_hostname in groups['octavia-api'] when: inventory_hostname in groups['octavia-api']
- include: "start.yml" - name: Flush handlers
when: inventory_hostname in groups['octavia-api'] or meta: flush_handlers
inventory_hostname in groups['octavia-health-manager'] or
inventory_hostname in groups['octavia-housekeeping'] or
inventory_hostname in groups['octavia-worker']

View File

@ -1,28 +1,10 @@
--- ---
- name: Pulling octavia-api image - name: Pulling octavia images
kolla_docker: kolla_docker:
action: "pull_image" action: "pull_image"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ octavia_api_image_full }}" image: "{{ item.value.image }}"
when: inventory_hostname in groups['octavia-api'] when:
- inventory_hostname in groups[item.value.group]
- name: Pulling octavia-health-manager image - item.value.enabled | bool
kolla_docker: with_dict: "{{ octavia_services }}"
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_health_manager_image_full }}"
when: inventory_hostname in groups['octavia-health-manager']
- name: Pulling octavia-housekeeping image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_housekeeping_image_full }}"
when: inventory_hostname in groups['octavia-housekeeping']
- name: Pulling octavia-worker image
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_worker_image_full }}"
when: inventory_hostname in groups['octavia-worker']

View File

@ -1,76 +1,2 @@
--- ---
- name: Ensuring the containers up - include: deploy.yml
kolla_docker:
name: "{{ item.name }}"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups[item.group]
with_items:
- { name: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- include: config.yml
- name: Check the configs
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups[item.group]
with_items:
- { name: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- name: Containers config strategy
kolla_docker:
name: "{{ item.name }}"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups[item.group]
with_items:
- { name: octavia_api, group: octavia-api }
- { name: octavia_health_manager, group: octavia-health-manager }
- { name: octavia_housekeeping, group: octavia-housekeeping }
- { name: octavia_worker, group: octavia-worker }
- name: Remove the containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "remove_container"
register: remove_containers
when:
- inventory_hostname in groups[item[0]['group']]
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[2]['rc'] == 1
with_together:
- [{ name: octavia_api, group: octavia-api },
{ name: octavia_health_manager, group: octavia-health-manager },
{ name: octavia_housekeeping, group: octavia-housekeeping },
{ name: octavia_worker, group: octavia-worker }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "{{ item[0]['name'] }}"
action: "restart_container"
when:
- inventory_hostname in groups[item[0]['group']]
- config_strategy == 'COPY_ALWAYS'
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[2]['rc'] == 1
with_together:
- [{ name: octavia_api, group: octavia-api },
{ name: octavia_health_manager, group: octavia-health-manager },
{ name: octavia_housekeeping, group: octavia-housekeeping },
{ name: octavia_worker, group: octavia-worker }]
- "{{ container_envs.results }}"
- "{{ check_results.results }}"

View File

@ -1,48 +0,0 @@
---
- name: Starting octavia-api container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_api_image_full }}"
name: "octavia_api"
volumes:
- "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-api']
- name: Starting octavia-health-manager container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_health_manager_image_full }}"
name: "octavia_health_manager"
volumes:
- "{{ node_config_directory }}/octavia-health-manager/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-health-manager']
- name: Starting octavia-housekeeping container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_housekeeping_image_full }}"
name: "octavia_housekeeping"
volumes:
- "{{ node_config_directory }}/octavia-housekeeping/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-housekeeping']
- name: Starting octavia-worker container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ octavia_worker_image_full }}"
name: "octavia_worker"
volumes:
- "{{ node_config_directory }}/octavia-worker/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['octavia-worker']

View File

@ -3,4 +3,5 @@
- include: "bootstrap_service.yml" - include: "bootstrap_service.yml"
- include: "start.yml" - name: Flush handlers
meta: flush_handlers