From 9b0a00865c2537338f72ed5b9b44a0d6bff16eb4 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 2 Jul 2026 10:26:55 +0200 Subject: [PATCH] ovs: Fix OVS path mismatch when building from source with OVN ``compile_ovs`` was called with ``--localstatedir=/var``, causing all compiled OVS binaries to hardcode ``/var/run/openvswitch`` as the default runtime directory. However, the ``ovn_agent`` plugin derives ``OVS_RUNDIR`` from ``OVS_PREFIX`` as ``/usr/local/var/run/openvswitch``, creating a path mismatch that makes ``ovs-vsctl`` unable to reach the running ``ovsdb-server``. Additionally, ``start_new_ovs`` was unconditionally starting OVS during the install phase. When OVN is the backend, ``ovn_agent:_start_ovs`` later starts its own OVS instance with a separate database, but the orphaned ``ovs-vswitchd`` from ``start_new_ovs`` still holds the kernel datapath, preventing bridge creation. Fix both issues: - Remove the ``--localstatedir=/var`` override so the compiled default matches ``OVS_RUNDIR`` (autotools defaults localstatedir to ``${prefix}/var``). - Skip ``start_new_ovs`` when OVN services are enabled, since ``_start_ovs`` handles the full OVS lifecycle. - Fix the hardcoded DB path in ``start_new_ovs`` to match the compiled ``--prefix=/usr/local`` sysconfdir. Closes-Bug: #2158954 Assisted-By: Claude Opus 4.6 Signed-off-by: Rodolfo Alonso Hernandez Change-Id: I8f3a2c5e7d1b4a9f6e0c3d8b2a5f7e1d4c6b9a0e --- lib/neutron_plugins/ovs_base | 10 ++++++++-- lib/neutron_plugins/ovs_source | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base index f2a35dd340..fb3a154a00 100644 --- a/lib/neutron_plugins/ovs_base +++ b/lib/neutron_plugins/ovs_base @@ -68,9 +68,15 @@ function _neutron_ovs_base_install_ubuntu_dkms { function _neutron_ovs_base_install_agent_packages { if [ "$Q_BUILD_OVS_FROM_GIT" == "True" ]; then remove_ovs_packages - compile_ovs /usr/local /var + compile_ovs /usr/local load_conntrack_gre_module - start_new_ovs + # When OVN is the backend, ovn_agent:_start_ovs handles OVS + # lifecycle with its own DB and rundir. Starting OVS here would + # leave an orphaned ovs-vswitchd holding the kernel datapath, + # preventing the OVN-managed instance from creating bridges. + if ! is_service_enabled ovn-controller ovn-northd; then + start_new_ovs + fi else # Install deps install_package $(get_packages "openvswitch") diff --git a/lib/neutron_plugins/ovs_source b/lib/neutron_plugins/ovs_source index feb8f0acd0..e141b22368 100644 --- a/lib/neutron_plugins/ovs_source +++ b/lib/neutron_plugins/ovs_source @@ -128,7 +128,8 @@ function action_openvswitch { # start_new_ovs() - removes old ovs database, creates a new one and starts ovs function start_new_ovs { - sudo rm -f /etc/openvswitch/conf.db /etc/openvswitch/.conf.db~lock~ + # DB path must match the compiled --prefix=/usr/local sysconfdir + sudo rm -f /usr/local/etc/openvswitch/conf.db /usr/local/etc/openvswitch/.conf.db~lock~ sudo /usr/local/share/openvswitch/scripts/ovs-ctl start }