diff mbox series

[ovs-dev,6/6] python: idl: Treat a "canceled" transaction reply as TRY_AGAIN.

Message ID 20260826043433.1832409-7-twilson@redhat.com
State New
Headers show
Series python: Backport C fixes that never made it. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_FreeBSD_Build_and_Test success github build: passed

Commit Message

Terry Wilson Aug. 26, 2026, 4:34 a.m. UTC
Port of C commit 1b1d2e6daa56 ("ovsdb: Introduce experimental support for
clustered databases").  A top-level JSON-RPC error reply of "canceled"
means ovsdb-server aborted the transaction because the database in
question was removed, converted, etc.; treat it as TRY_AGAIN rather than a
hard error.  For any other top-level error, and for a reply that is not a
JSON array, record the offending JSON on the transaction so the client can
inspect it.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Terry Wilson <twilson@redhat.com>
---
 python/ovs/db/idl.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 30bc6cb44..15d7ce732 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -2239,10 +2239,19 @@  class Transaction(object):
 
     def _process_reply(self, msg):
         if msg.type == ovs.jsonrpc.Message.T_ERROR:
-            self._status = Transaction.ERROR
+            if msg.error == "canceled":
+                # ovsdb-server uses this error message to indicate that the
+                # transaction was canceled because the database in question was
+                # removed, converted, etc.
+                self._status = Transaction.TRY_AGAIN
+            else:
+                self._status = Transaction.ERROR
+                self.__set_error_json(msg.error)
         elif not isinstance(msg.result, (list, tuple)):
             # XXX rate-limit
             vlog.warn('reply to "transact" is not JSON array')
+            self._status = Transaction.ERROR
+            self.__set_error_json(msg.result)
         else:
             hard_errors = False
             soft_errors = False