Skip to content

Commit de72559

Browse files
mnasiadkaseunghun1ee
authored andcommitted
ovn: Add support for OVN SB Relay
Add support for deploying OVN SB relays [1]. This is enabled by default to improve large scale scenarios. Default mechanism deploys one relay group per 50 ovn-controller hosts and uses random but idempotent method to choose a relay for a given host. neutron-server will connect directly to SB cluster, not via the relays. [1]: https://docs.ovn.org/en/latest/tutorials/ovn-ovsdb-relay.html Co-Authored-By: Krzysztof Tomaszewski <ktomaszewski@cloudferro.com> Depends-On: https://review.opendev.org/c/openstack/kolla/+/928898 Change-Id: Id7d6973668d8b2b194913b533f8cb756c6708536 (cherry picked from commit 7b95939)
1 parent f890617 commit de72559

File tree

20 files changed

+272
-4
lines changed

20 files changed

+272
-4
lines changed

ansible/group_vars/all.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,16 @@ opensearch_dashboards_listen_port: "{{ opensearch_dashboards_port }}"
616616

617617
ovn_nb_db_port: "6641"
618618
ovn_sb_db_port: "6642"
619+
# OVN SB Relay related variables
620+
ovn_sb_db_relay_count: "{{ ((groups['ovn-controller'] | length) / ovn_sb_db_relay_compute_per_relay | int) | round(0, 'ceil') | int }}"
621+
ovn_sb_db_relay_compute_per_relay: "50"
622+
ovn_sb_db_relay_port_prefix: "1664"
623+
ovn_sb_db_relay_port: "{{ ovn_sb_db_relay_port_prefix ~ ovn_sb_db_relay_client_group_id }}"
624+
ovn_sb_db_relay_client_group_id: "{{ range(1, ovn_sb_db_relay_count | int + 1) | random(seed=inventory_hostname) }}"
619625
ovn_nb_connection: "{% for host in groups['ovn-nb-db'] %}tcp:{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ ovn_nb_db_port }}{% if not loop.last %},{% endif %}{% endfor %}"
620-
ovn_sb_connection: "{% for host in groups['ovn-sb-db'] %}tcp:{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ ovn_sb_db_port }}{% if not loop.last %},{% endif %}{% endfor %}"
626+
ovn_sb_connection: "{{ ovn_sb_connection_relay if enable_ovn_sb_db_relay | bool else ovn_sb_connection_no_relay }}"
627+
ovn_sb_connection_no_relay: "{% for host in groups['ovn-sb-db'] %}tcp:{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ ovn_sb_db_port }}{% if not loop.last %},{% endif %}{% endfor %}"
628+
ovn_sb_connection_relay: "{% for host in groups['ovn-sb-db-relay'] %}tcp:{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ ovn_sb_db_relay_port }}{% if not loop.last %},{% endif %}{% endfor %}"
621629

622630
ovsdb_port: "6640"
623631

@@ -924,6 +932,7 @@ enable_octavia_driver_agent: "{{ enable_octavia | bool and neutron_plugin_agent
924932
enable_octavia_jobboard: "{{ enable_octavia | bool and 'amphora' in octavia_provider_drivers }}"
925933
enable_openvswitch: "{{ enable_neutron | bool and neutron_plugin_agent != 'linuxbridge' }}"
926934
enable_ovn: "{{ enable_neutron | bool and neutron_plugin_agent == 'ovn' }}"
935+
enable_ovn_sb_db_relay: "no"
927936
enable_ovs_dpdk: "no"
928937
enable_osprofiler: "no"
929938
enable_placement: "{{ enable_nova | bool or enable_zun | bool }}"

ansible/inventory/all-in-one

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ ovn-database
592592
[ovn-sb-db:children]
593593
ovn-database
594594

595+
[ovn-sb-db-relay:children]
596+
ovn-database
597+
595598
[venus-api:children]
596599
venus
597600

ansible/inventory/multinode

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ ovn-database
611611
[ovn-sb-db:children]
612612
ovn-database
613613

614+
[ovn-sb-db-relay:children]
615+
ovn-database
616+
614617
[venus-api:children]
615618
venus
616619

ansible/roles/neutron/templates/ml2_conf.ini.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ max_header_size = 38
3737

3838
[ovn]
3939
ovn_nb_connection = {{ ovn_nb_connection }}
40-
ovn_sb_connection = {{ ovn_sb_connection }}
40+
ovn_sb_connection = {{ ovn_sb_connection_no_relay }}
4141
ovn_metadata_enabled = True
4242
enable_distributed_floating_ip = {{ neutron_ovn_distributed_fip | bool }}
4343
ovn_emit_need_to_frag = True

ansible/roles/octavia/templates/octavia.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enabled_provider_agents = {{ octavia_provider_agents }}
2929
{% if neutron_plugin_agent == 'ovn' %}
3030
[ovn]
3131
ovn_nb_connection = {{ ovn_nb_connection }}
32-
ovn_sb_connection = {{ ovn_sb_connection }}
32+
ovn_sb_connection = {{ ovn_sb_connection_no_relay }}
3333
{% endif %}
3434

3535
[haproxy_amphora]

ansible/roles/ovn-db/defaults/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ ovn_db_services:
2121
image: "{{ ovn_sb_db_image_full }}"
2222
volumes: "{{ ovn_sb_db_default_volumes + ovn_sb_db_extra_volumes }}"
2323
dimensions: "{{ ovn_sb_db_dimensions }}"
24+
ovn-sb-db-relay:
25+
container_name: ovn_sb_db_relay
26+
group: ovn-sb-db-relay
27+
enabled: "{{ enable_ovn_sb_db_relay | bool }}"
28+
image: "{{ ovn_sb_db_relay_image_full }}"
29+
iterate: true
30+
iterate_var: "{{ ovn_sb_db_relay_count | int }}"
31+
volumes: "{{ ovn_sb_db_relay_default_volumes + ovn_sb_db_relay_extra_volumes }}"
32+
dimensions: "{{ ovn_sb_db_relay_dimensions }}"
2433

2534

2635
####################
@@ -40,9 +49,14 @@ ovn_sb_db_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docke
4049
ovn_sb_db_tag: "{{ ovn_tag }}"
4150
ovn_sb_db_image_full: "{{ ovn_sb_db_image }}:{{ ovn_sb_db_tag }}"
4251

52+
ovn_sb_db_relay_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/ovn-sb-db-relay"
53+
ovn_sb_db_relay_tag: "{{ ovn_tag }}"
54+
ovn_sb_db_relay_image_full: "{{ ovn_sb_db_relay_image }}:{{ ovn_sb_db_relay_tag }}"
55+
4356
ovn_northd_dimensions: "{{ default_container_dimensions }}"
4457
ovn_nb_db_dimensions: "{{ default_container_dimensions }}"
4558
ovn_sb_db_dimensions: "{{ default_container_dimensions }}"
59+
ovn_sb_db_relay_dimensions: "{{ default_container_dimensions }}"
4660

4761
ovn_northd_default_volumes:
4862
- "{{ node_config_directory }}/ovn-northd/:{{ container_config_directory }}/:ro"
@@ -58,11 +72,16 @@ ovn_sb_db_default_volumes:
5872
- "/etc/localtime:/etc/localtime:ro"
5973
- "ovn_sb_db:/var/lib/openvswitch/ovn-sb/"
6074
- "kolla_logs:/var/log/kolla/"
75+
ovn_sb_db_relay_default_volumes:
76+
- "{{ node_config_directory }}/ovn-sb-db-relay{{ ('-' + item | string) if item is defined }}/:{{ container_config_directory }}/:ro"
77+
- "/etc/localtime:/etc/localtime:ro"
78+
- "kolla_logs:/var/log/kolla/"
6179

6280
ovn_db_extra_volumes: "{{ default_extra_volumes }}"
6381
ovn_northd_extra_volumes: "{{ ovn_db_extra_volumes }}"
6482
ovn_nb_db_extra_volumes: "{{ ovn_db_extra_volumes }}"
6583
ovn_sb_db_extra_volumes: "{{ ovn_db_extra_volumes }}"
84+
ovn_sb_db_relay_extra_volumes: "{{ ovn_db_extra_volumes }}"
6685

6786
#####
6887
# OVN
@@ -75,6 +94,19 @@ ovn_openflow_probe_interval: "60"
7594
ovn_db_inactivity_probe: "60000"
7695
ovn_sb_db_inactivity_probe: "{{ ovn_db_inactivity_probe }}"
7796
ovn_nb_db_inactivity_probe: "{{ ovn_db_inactivity_probe }}"
97+
ovn_sb_db_relay_active_inactivity_probe: "{{ ovn_db_inactivity_probe | int * 2}}"
98+
ovn_sb_db_relay_passive_inactivity_probe: "{{ ovn_db_inactivity_probe }}"
99+
ovn_sb_db_relay_max_backoff: "{{ ovn_db_inactivity_probe }}"
100+
101+
# TODO(mnnasiadka): remove that once Debian gets OVS 3.3+
102+
ovn_sb_db_relay_config_file_args: >-
103+
{% if kolla_base_distro == 'debian' %}
104+
--db-sb-relay-remote={{ ovn_sb_connection_no_relay }}
105+
-- --remote=ptcp:{{ ovn_sb_db_relay_port_prefix ~ ovn_sb_db_relay_group_id }}:{{ api_interface_address | put_address_in_context('url') }}
106+
{% else %}
107+
--db-sb-relay-config-file=/etc/ovn/ovsdb-relay.json
108+
{% endif %}
109+
78110
# OVN startup commands
79111
ovn_nb_command: >-
80112
/usr/share/ovn/scripts/ovn-ctl run_nb_ovsdb
@@ -94,5 +126,13 @@ ovn_sb_command: >-
94126
--db-sb-pidfile=/run/ovn/ovnsb_db.pid
95127
--db-sb-file=/var/lib/openvswitch/ovn-sb/ovnsb.db
96128
--ovn-sb-logfile=/var/log/kolla/openvswitch/ovn-sb-db.log
129+
ovn_sb_relay_command: >-
130+
/usr/share/ovn/scripts/ovn-ctl run_sb_relay_ovsdb
131+
--db-sb-relay-ctrl-sock=/run/ovn/ovnsb_db_relay_{{ ovn_sb_db_relay_group_id }}.ctl
132+
--db-sb-relay-pidfile=/run/ovn/ovnsb_db_relay_{{ ovn_sb_db_relay_group_id }}.pid
133+
--db-sb-relay-sock=/run/ovn/ovnsb_db_{{ ovn_sb_db_relay_group_id }}.sock
134+
--db-sb-relay-use-remote-in-db=no
135+
--ovn-sb-relay-logfile=/var/log/kolla/openvswitch/ovn-sb-relay-{{ ovn_sb_db_relay_group_id }}.log
136+
{{ ovn_sb_db_relay_config_file_args }}
97137
# Workaround: pause after restarting containers to allow for leader election.
98138
ovn_leader_election_pause: 5

ansible/roles/ovn-db/handlers/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@
2525
volumes: "{{ service.volumes | reject('equalto', '') | list }}"
2626
dimensions: "{{ service.dimensions }}"
2727

28+
- name: Restart ovn-sb-db-relay container
29+
vars:
30+
service_name: "ovn-sb-db-relay"
31+
service: "{{ ovn_db_services[service_name] }}"
32+
become: true
33+
kolla_container:
34+
action: "recreate_or_restart_container"
35+
common_options: "{{ docker_common_options }}"
36+
name: "{{ service.container_name }}_{{ item }}"
37+
image: "{{ service.image }}"
38+
volumes: "{{ service.volumes | reject('equalto', '') | list }}"
39+
dimensions: "{{ service.dimensions }}"
40+
loop: "{{ range(1, (ovn_sb_db_relay_count | int) + 1) | list }}"
41+
2842
- name: Restart ovn-northd container
2943
vars:
3044
service_name: "ovn-northd"

ansible/roles/ovn-db/tasks/bootstrap-db.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,20 @@
5656
until: check_ovn_sb_db_port is success
5757
retries: 10
5858
delay: 6
59+
60+
- name: Wait for ovn-sb-db-relay
61+
vars:
62+
ovn_sb_db_relay_group_id: "{{ item }}"
63+
ovn_sb_db_relay_port: "{{ ovn_sb_db_relay_port_prefix ~ ovn_sb_db_relay_group_id }}"
64+
wait_for:
65+
host: "{{ api_interface_address }}"
66+
port: "{{ ovn_sb_db_relay_port }}"
67+
connect_timeout: 1
68+
timeout: 60
69+
register: check_ovn_sb_db_relay_port
70+
until: check_ovn_sb_db_relay_port is success
71+
retries: 10
72+
delay: 6
73+
when:
74+
- enable_ovn_sb_db_relay | bool
75+
loop: "{{ range(1, (ovn_sb_db_relay_count | int) +1) }}"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Ensuring config directories exist for OVN relay containers
3+
vars:
4+
ovn_sb_db_relay_group_id: "{{ item }}"
5+
file:
6+
path: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}"
7+
state: "directory"
8+
owner: "{{ config_owner_user }}"
9+
group: "{{ config_owner_group }}"
10+
mode: "0770"
11+
become: true
12+
13+
- name: Copying over config.json files for OVN relay services
14+
vars:
15+
# NOTE(mnasiadka): Used in the ovn_sb_relay_command template in defaults/main.yml
16+
ovn_sb_db_relay_group_id: "{{ item }}"
17+
template:
18+
src: "ovn-sb-db-relay.json.j2"
19+
dest: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}/config.json"
20+
mode: "0660"
21+
become: true
22+
notify:
23+
- Restart ovn-sb-db-relay container
24+
25+
- name: Generate config files for OVN relay services
26+
vars:
27+
# NOTE(mnasiadka): Used in the ovn_sb_relay_command template in defaults/main.yml
28+
ovn_sb_db_relay_group_id: "{{ item }}"
29+
template:
30+
src: "ovsdb-relay.json.j2"
31+
dest: "{{ node_config_directory }}/ovn-sb-db-relay-{{ item }}/ovsdb-relay.json"
32+
mode: "0660"
33+
become: true
34+
notify:
35+
- Restart ovn-sb-db-relay container

ansible/roles/ovn-db/tasks/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
mode: "0770"
99
become: true
1010
with_dict: "{{ ovn_db_services | select_services_enabled_and_mapped_to_host }}"
11+
when: item.key != 'ovn-sb-db-relay'
1112

1213
- name: Copying over config.json files for services
1314
template:
@@ -16,3 +17,11 @@
1617
mode: "0660"
1718
become: true
1819
with_dict: "{{ ovn_db_services | select_services_enabled_and_mapped_to_host }}"
20+
notify:
21+
- Restart {{ item.key }} container
22+
when: item.key != 'ovn-sb-db-relay'
23+
24+
- name: Ensure configuration for relays exists
25+
include_tasks: config-relay.yml
26+
loop: "{{ range(1, ovn_sb_db_relay_count | int + 1) | list }}"
27+
when: enable_ovn_sb_db_relay | bool

0 commit comments

Comments
 (0)