ovn: Break out role into ovn-db and ovn-controller roles

Instead of handling everything in one role - let's have small
fit-for-purpose roles, because in reality these are two hosts
roles and performance should be better with this approach.

[1]: https://docs.ovn.org/en/latest/intro/install/ovn-upgrades.html

Change-Id: I8f9dbe9d950323f16375ad5e1dbaedfb1be6585f
This commit is contained in:
Michal Nasiadka 2022-06-27 13:38:16 +02:00
parent 68376d6f31
commit 63a7968d8d
35 changed files with 160 additions and 64 deletions

View File

@ -0,0 +1,38 @@
---
ovn_controller_services:
ovn-controller:
container_name: ovn_controller
group: ovn-controller
enabled: true
image: "{{ ovn_controller_image_full }}"
volumes: "{{ ovn_controller_default_volumes + ovn_controller_extra_volumes }}"
dimensions: "{{ ovn_controller_dimensions }}"
####################
# Docker
####################
ovn_tag: "{{ openstack_tag }}"
ovn_controller_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/ovn-controller"
ovn_controller_tag: "{{ ovn_tag }}"
ovn_controller_image_full: "{{ ovn_controller_image }}:{{ ovn_controller_tag }}"
ovn_controller_dimensions: "{{ default_container_dimensions }}"
ovn_controller_default_volumes:
- "{{ node_config_directory }}/ovn-controller/:{{ container_config_directory }}/:ro"
- "/run/openvswitch:/run/openvswitch:shared"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
ovn_controller_extra_volumes: "{{ default_extra_volumes }}"
#####
# OVN
#####
# Base MAC for ovn-chassis-mac-mappings generation
ovn_base_mac: "52:54:00"
# Configure OVN remote probe interval time in ms
ovn_remote_probe_interval: "60000"
# Configure OVN openflow interval in s
ovn_openflow_probe_interval: "60"

View File

@ -0,0 +1,15 @@
---
- name: Restart ovn-controller container
vars:
service_name: "ovn-controller"
service: "{{ ovn_controller_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 | reject('equalto', '') | list }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"

View File

@ -0,0 +1,16 @@
---
- name: Check ovn-controller containers
become: true
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
volumes: "{{ item.value.volumes | reject('equalto', '') | list }}"
dimensions: "{{ item.value.dimensions }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_controller_services }}"
notify:
- Restart {{ item.key }} container

View File

@ -0,0 +1,26 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_controller_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_controller_services }}"
notify:
- Restart {{ item.key }} container

View File

@ -3,8 +3,7 @@
- import_tasks: check-containers.yml
- import_tasks: bootstrap.yml
when: inventory_hostname in groups['ovn-controller']
- import_tasks: setup-ovs.yml
- name: Flush handlers
meta: flush_handlers

View File

@ -0,0 +1,6 @@
---
- import_role:
role: service-stop
vars:
project_services: "{{ ovn_controller_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,2 @@
---
- import_tasks: deploy.yml

View File

@ -0,0 +1,6 @@
---
project_name: "ovn"
# NOTE(mnasiadka): we need this for the ovn-controller role
# because this role's vars prefix does not match "{{ project_name }}"
kolla_role_name: "ovn_controller"

View File

@ -1,12 +1,5 @@
---
ovn_services:
ovn-controller:
container_name: ovn_controller
group: ovn-controller
enabled: true
image: "{{ ovn_controller_image_full }}"
volumes: "{{ ovn_controller_default_volumes + ovn_controller_extra_volumes }}"
dimensions: "{{ ovn_controller_dimensions }}"
ovn_db_services:
ovn-northd:
container_name: ovn_northd
group: ovn-northd
@ -35,10 +28,6 @@ ovn_services:
####################
ovn_tag: "{{ openstack_tag }}"
ovn_controller_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/ovn-controller"
ovn_controller_tag: "{{ ovn_tag }}"
ovn_controller_image_full: "{{ ovn_controller_image }}:{{ ovn_controller_tag }}"
ovn_northd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/ovn-northd"
ovn_northd_tag: "{{ ovn_tag }}"
ovn_northd_image_full: "{{ ovn_northd_image }}:{{ ovn_northd_tag }}"
@ -51,16 +40,10 @@ ovn_sb_db_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docke
ovn_sb_db_tag: "{{ ovn_tag }}"
ovn_sb_db_image_full: "{{ ovn_sb_db_image }}:{{ ovn_sb_db_tag }}"
ovn_controller_dimensions: "{{ default_container_dimensions }}"
ovn_northd_dimensions: "{{ default_container_dimensions }}"
ovn_nb_db_dimensions: "{{ default_container_dimensions }}"
ovn_sb_db_dimensions: "{{ default_container_dimensions }}"
ovn_controller_default_volumes:
- "{{ node_config_directory }}/ovn-controller/:{{ container_config_directory }}/:ro"
- "/run/openvswitch:/run/openvswitch:shared"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
ovn_northd_default_volumes:
- "{{ node_config_directory }}/ovn-northd/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
@ -76,18 +59,7 @@ ovn_sb_db_default_volumes:
- "ovn_sb_db:/var/lib/openvswitch/ovn-sb/"
- "kolla_logs:/var/log/kolla/"
ovn_extra_volumes: "{{ default_extra_volumes }}"
ovn_controller_extra_volumes: "{{ ovn_extra_volumes }}"
ovn_northd_extra_volumes: "{{ ovn_extra_volumes }}"
ovn_nb_db_extra_volumes: "{{ ovn_extra_volumes }}"
ovn_sb_db_extra_volumes: "{{ ovn_extra_volumes }}"
#####
# OVN
#####
# Base MAC for ovn-chassis-mac-mappings generation
ovn_base_mac: "52:54:00"
# Configure OVN remote probe interval time in ms
ovn_remote_probe_interval: "60000"
# Configure OVN openflow interval in s
ovn_openflow_probe_interval: "60"
ovn_db_extra_volumes: "{{ default_extra_volumes }}"
ovn_northd_extra_volumes: "{{ ovn_db_extra_volumes }}"
ovn_nb_db_extra_volumes: "{{ ovn_db_extra_volumes }}"
ovn_sb_db_extra_volumes: "{{ ovn_db_extra_volumes }}"

View File

@ -2,7 +2,7 @@
- name: Restart ovn-nb-db container
vars:
service_name: "ovn-nb-db"
service: "{{ ovn_services[service_name] }}"
service: "{{ ovn_db_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -17,7 +17,7 @@
- name: Restart ovn-sb-db container
vars:
service_name: "ovn-sb-db"
service: "{{ ovn_services[service_name] }}"
service: "{{ ovn_db_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
@ -60,22 +60,7 @@
- name: Restart ovn-northd container
vars:
service_name: "ovn-northd"
service: "{{ ovn_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 | reject('equalto', '') | list }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"
- name: Restart ovn-controller container
vars:
service_name: "ovn-controller"
service: "{{ ovn_services[service_name] }}"
service: "{{ ovn_db_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"

View File

@ -11,6 +11,6 @@
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_services }}"
with_dict: "{{ ovn_db_services }}"
notify:
- Restart {{ item.key }} container

View File

@ -10,7 +10,7 @@
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_services }}"
with_dict: "{{ ovn_db_services }}"
- name: Copying over config.json files for services
template:
@ -21,6 +21,6 @@
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ ovn_services }}"
with_dict: "{{ ovn_db_services }}"
notify:
- Restart {{ item.key }} container

View File

@ -0,0 +1,2 @@
---
- import_tasks: check-containers.yml

View File

@ -0,0 +1,2 @@
---
- include_tasks: "{{ kolla_action }}.yml"

View File

@ -0,0 +1,3 @@
---
- import_role:
role: service-images-pull

View File

@ -0,0 +1,2 @@
---
- import_tasks: deploy.yml

View File

@ -2,5 +2,5 @@
- import_role:
role: service-stop
vars:
project_services: "{{ ovn_services }}"
project_services: "{{ ovn_db_services }}"
service_name: "{{ project_name }}"

View File

@ -0,0 +1,2 @@
---
- import_tasks: deploy.yml

View File

@ -0,0 +1,6 @@
---
project_name: "ovn"
# NOTE(mnasiadka): we need this for the ovn-db role because this role's
# vars prefix does not match "{{ project_name }}"
kolla_role_name: "ovn_db"

View File

@ -1,2 +0,0 @@
---
project_name: "ovn"

View File

@ -651,18 +651,27 @@
tags: ovs-dpdk,
when: "(enable_openvswitch | bool) and (enable_ovs_dpdk | bool)"}
- name: Apply role ovn
- name: Apply role ovn-db
gather_facts: false
hosts:
- ovn-controller
- ovn-nb-db
- ovn-northd
- ovn-sb-db
- '&enable_ovn_True'
serial: '{{ kolla_serial|default("0") }}'
roles:
- { role: ovn,
tags: ovn }
- { role: ovn-db,
tags: [ovn, ovn-db] }
- name: Apply role ovn-controller
gather_facts: false
hosts:
- ovn-controller
- '&enable_ovn_True'
serial: '{{ kolla_serial|default("0") }}'
roles:
- { role: ovn-controller,
tags: [ovn, ovn-controller] }
- name: Apply role neutron
gather_facts: false

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
``ovn`` role has been split into ``ovn-controller`` and ``ovn-db``
roles, therefore users that have ``ovn_extra_volumes`` configured
need to adapt their config to use ``ovn_db_extra_volumes`` or
``ovn_controller_extra_volumes``.

View File

@ -196,7 +196,7 @@
parent: kolla-ansible-base
voting: false
files:
- ^ansible/roles/(neutron|octavia|openvswitch|ovn)/
- ^ansible/roles/(neutron|octavia|openvswitch|ovn-controller|ovn-db)/
- ^tests/test-ovn.sh
- ^tests/test-core-openstack.sh
vars: