Skip to content

Commit

Permalink
python: idl: Handle monitor_canceled.
Browse files Browse the repository at this point in the history
Currently python-ovs claims to be "db change aware" but does not
parse the "monitor_canceled" notification. Transactions can continue
being made, but the monitor updates will not be sent. This handles
monitor_cancel similarly to how ovsdb-cs currently does.

Fixes: c39751e ("python: Monitor Database table to manage lifecycle of IDL client.")
Signed-off-by: Terry Wilson <twilson@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Simon Horman <horms@ovn.org>
  • Loading branch information
otherwiseguy authored and Simon Horman committed Jan 11, 2024
1 parent c8d85a0 commit ac04dfa
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions python/ovs/db/idl.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def __init__(self, remote, schema_helper, probe_interval=None,
self._server_schema_request_id = None
self._server_monitor_request_id = None
self._db_change_aware_request_id = None
self._monitor_cancel_request_id = None
self._server_db_name = '_Server'
self._server_db_table = 'Database'
self.server_tables = None
Expand Down Expand Up @@ -481,6 +482,10 @@ def run(self):
break
else:
self.__parse_update(msg.params[1], OVSDB_UPDATE)
elif self.handle_monitor_canceled(msg):
break
elif self.handle_monitor_cancel_reply(msg):
break
elif (msg.type == ovs.jsonrpc.Message.T_REPLY
and self._monitor_request_id is not None
and self._monitor_request_id == msg.id):
Expand Down Expand Up @@ -616,6 +621,33 @@ def run(self):

return initial_change_seqno != self.change_seqno

def handle_monitor_canceled(self, msg):
if msg.type != msg.T_NOTIFY:
return False
if msg.method != "monitor_canceled":
return False

if msg.params[0] == str(self.uuid):
params = [str(self.server_monitor_uuid)]
elif msg.params[0] == str(self.server_monitor_uuid):
params = [str(self.uuid)]
else:
return False

mc_msg = ovs.jsonrpc.Message.create_request("monitor_cancel", params)
self._monitor_cancel_request_id = mc_msg.id
self.send_request(mc_msg)
self.restart_fsm()
return True

def handle_monitor_cancel_reply(self, msg):
if msg.type != msg.T_REPLY:
return False
if msg.id != self._monitor_cancel_request_id:
return False
self._monitor_cancel_request_id = None
return True

def compose_cond_change(self):
if not self.cond_changed:
return
Expand Down

0 comments on commit ac04dfa

Please sign in to comment.