Skip to content

Commit 511208f

Browse files
committed
ovn-db: Add OVN_NB_DB and OVN_SB_DB env variables
It will make running ovn-nbctl and ovn-sbctl working on all nodes irrespective of their cluster role. Excerpt from ovn-nbctl: --db database The OVSDB database remote to contact. If the OVN_NB_DB en‐ vironment variable is set, its value is used as the de‐ fault. Otherwise, the default is unix:/ovnnb_db.sock, but this default is unlikely to be useful outside of single-ma‐ chine OVN test environments. Closes-Bug: #2116313 Change-Id: I85f7bfd0aaa6f2d426ddb28950acbbca9d385aac Signed-off-by: Michal Nasiadka <[email protected]> (cherry picked from commit bdd98ec)
1 parent d66e506 commit 511208f

File tree

7 files changed

+55
-6
lines changed

7 files changed

+55
-6
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ ovn_db_services:
44
container_name: ovn_northd
55
group: ovn-northd
66
enabled: true
7+
environment:
8+
OVN_NB_DB: "{{ ovn_nb_connection }}"
9+
OVN_SB_DB: "{{ ovn_sb_connection_no_relay }}"
710
image: "{{ ovn_northd_image_full }}"
811
volumes: "{{ ovn_northd_default_volumes + ovn_northd_extra_volumes }}"
912
dimensions: "{{ ovn_northd_dimensions }}"
1013
ovn-nb-db:
1114
container_name: ovn_nb_db
1215
group: ovn-nb-db
1316
enabled: true
17+
environment:
18+
OVN_NB_DB: "{{ ovn_nb_connection }}"
1419
image: "{{ ovn_nb_db_image_full }}"
1520
volumes: "{{ ovn_nb_db_default_volumes + ovn_nb_db_extra_volumes }}"
1621
dimensions: "{{ ovn_nb_db_dimensions }}"
1722
ovn-sb-db:
1823
container_name: ovn_sb_db
1924
group: ovn-sb-db
2025
enabled: true
26+
environment:
27+
OVN_SB_DB: "{{ ovn_sb_connection_no_relay }}"
2128
image: "{{ ovn_sb_db_image_full }}"
2229
volumes: "{{ ovn_sb_db_default_volumes + ovn_sb_db_extra_volumes }}"
2330
dimensions: "{{ ovn_sb_db_dimensions }}"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
kolla_container:
88
action: "recreate_or_restart_container"
99
common_options: "{{ docker_common_options }}"
10+
environment: "{{ service.environment }}"
1011
name: "{{ service.container_name }}"
1112
image: "{{ service.image }}"
1213
volumes: "{{ service.volumes | reject('equalto', '') | list }}"
@@ -20,6 +21,7 @@
2021
kolla_container:
2122
action: "recreate_or_restart_container"
2223
common_options: "{{ docker_common_options }}"
24+
environment: "{{ service.environment }}"
2325
name: "{{ service.container_name }}"
2426
image: "{{ service.image }}"
2527
volumes: "{{ service.volumes | reject('equalto', '') | list }}"
@@ -48,6 +50,7 @@
4850
kolla_container:
4951
action: "recreate_or_restart_container"
5052
common_options: "{{ docker_common_options }}"
53+
environment: "{{ service.environment }}"
5154
name: "{{ service.container_name }}"
5255
image: "{{ service.image }}"
5356
volumes: "{{ service.volumes | reject('equalto', '') | list }}"

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
become: true
2525
command: >-
2626
{{ kolla_container_engine }} exec ovn_nb_db
27-
ovn-nbctl --inactivity-probe={{ ovn_nb_db_inactivity_probe }}
27+
ovn-nbctl
28+
--db unix:/var/run/ovn/ovnnb_db.sock
29+
--inactivity-probe={{ ovn_nb_db_inactivity_probe }}
2830
set-connection ptcp:{{ ovn_nb_db_port }}:0.0.0.0
2931
register: ovn_nb_set_connection_result
3032
retries: 3
@@ -47,7 +49,9 @@
4749
become: true
4850
command: >-
4951
{{ kolla_container_engine }} exec ovn_sb_db
50-
ovn-sbctl --inactivity-probe={{ ovn_sb_db_inactivity_probe }}
52+
ovn-sbctl
53+
--db unix:/var/run/ovn/ovnsb_db.sock
54+
--inactivity-probe={{ ovn_sb_db_inactivity_probe }}
5155
set-connection ptcp:{{ ovn_sb_db_port }}:0.0.0.0
5256
register: ovn_sb_set_connection_result
5357
retries: 3

doc/source/reference/networking/neutron.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ In order to deploy Neutron OVN Agent you need to set the following:
279279
280280
Currently the agent is only needed for QoS for hardware offloaded ports.
281281

282+
When in need of running `ovn-nbctl` or `ovn-sbctl` commands it's most
283+
convenient to run them from ``ovn_northd`` container:
284+
285+
.. code-block:: console
286+
287+
docker exec ovn_northd ovn-nbctl show
288+
282289
Mellanox Infiniband (ml2/mlnx)
283290
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284291

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
The OVN container images (``ovn-nb-db``, ``ovn-northd`` and ``ovn-sb-db``)
5+
have now default environment variables in place that ease running of
6+
``ovn-nbctl`` and ``ovn-sbctl`` commands for operators.

tests/run.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@
439439
when: scenario == "ovn"
440440
environment:
441441
CONTAINER_ENGINE: "{{ container_engine }}"
442+
IS_UPGRADE: "{{ is_upgrade | bool | ternary('yes', 'no') }}"
442443

443444
- name: Run test-core-openstack.sh script
444445
script:

tests/test-ovn.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ function test_ovn {
1515

1616
# List OVN NB/SB entries
1717
echo "OVN NB DB entries:"
18-
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" show
18+
# TODO(mnasiadka): Remove the first part of conditional in G cycle
19+
if [ $IS_UPGRADE == "yes" ]; then
20+
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" show
21+
else
22+
sudo ${container_engine} exec ovn_northd ovn-nbctl show
23+
fi
1924

2025
echo "OVN SB DB entries:"
21-
sudo ${container_engine} exec ovn_northd ovn-sbctl --db "$ovn_sb_connection" show
26+
# TODO(mnasiadka): Remove the first part of conditional in G cycle
27+
if [ $IS_UPGRADE == "yes" ]; then
28+
sudo ${container_engine} exec ovn_northd ovn-sbctl --db "$ovn_sb_connection" show
29+
else
30+
sudo ${container_engine} exec ovn_northd ovn-sbctl show
31+
fi
2232

2333
OVNNB_STATUS=$(sudo ${container_engine} exec ovn_nb_db ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound)
2434
OVNSB_STATUS=$(sudo ${container_engine} exec ovn_sb_db ovs-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound)
@@ -92,9 +102,20 @@ function test_octavia {
92102
openstack floating ip set $lb_fip --port $lb_port_id
93103

94104
echo "OVN NB entries for LB:"
95-
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" list load_balancer
105+
# TODO(mnasiadka): Remove the first part of conditional in G cycle
106+
if [ $IS_UPGRADE == "yes" ]; then
107+
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" list load_balancer
108+
else
109+
sudo ${container_engine} exec ovn_northd ovn-nbctl list load_balancer
110+
fi
111+
96112
echo "OVN NB entries for NAT:"
97-
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" list nat
113+
# TODO(mnasiadka): Remove the first part of conditional in G cycle
114+
if [ $IS_UPGRADE == "yes" ]; then
115+
sudo ${container_engine} exec ovn_northd ovn-nbctl --db "$ovn_nb_connection" list nat
116+
else
117+
sudo ${container_engine} exec ovn_northd ovn-nbctl list nat
118+
fi
98119

99120
echo "Attempt to access the load balanced HTTP server."
100121
attempts=12

0 commit comments

Comments
 (0)