chassis_idx_stored is set before the transaction result is known.
If the transaction fails, ovn-controller never stores its index.

Call the idempotent helper for every available transaction.  This lets
ovn-controller retry until the index is present.  Add a regression test
which removes the index and waits for ovn-controller to restore it.

Fixes: dae2eb8a17cc ("controller: support multiple chassis instances on the 
same host")
Signed-off-by: Ihar Hrachyshka <[email protected]>
Assisted-by: Codex, gpt-5.6-sol high
---
 controller/ovn-controller.c | 4 +---
 tests/ovn.at                | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index c601f89dc..796f1aecc 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -8311,10 +8311,8 @@ main(int argc, char *argv[])
             }
         }
 
-        static bool chassis_idx_stored = false;
-        if (ovs_idl_txn && !chassis_idx_stored) {
+        if (ovs_idl_txn) {
             store_chassis_index_if_needed(ovs_table);
-            chassis_idx_stored = true;
         }
 
         if (ovsdb_idl_has_ever_connected(ovnsb_idl_loop.idl) &&
diff --git a/tests/ovn.at b/tests/ovn.at
index 13e95f9db..a893d254c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -39120,6 +39120,10 @@ ovn_attach n1 br-phys 192.168.0.1
 OVS_WAIT_UNTIL([ovs-vsctl get Open_vSwitch . other_config:ovn-chassis-idx-hv1])
 OVS_WAIT_UNTIL([test x$(ovs-vsctl get Open_vSwitch . 
other_config:ovn-chassis-idx-hv1) = 'x""'])
 
+# check that ovn-controller restores its chassis index if it is removed
+ovs-vsctl remove Open_vSwitch . other_config ovn-chassis-idx-hv1
+OVS_WAIT_UNTIL([ovs-vsctl get Open_vSwitch . other_config:ovn-chassis-idx-hv1])
+
 # exit ovn-controller which should clean up allocated index in the database
 OVS_APP_EXIT_AND_WAIT([ovn-controller])
 
-- 
2.54.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to