Message ID | 20210616103214.35669-1-b.petermann@syseleven.de |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] Python: Fix Idl.run change_seqno update | expand |
From: Alin Gabriel Serdean <aserdean@ovn.org> >Fix an issue where Idl.run() returned False even if there was a change. >If Idl.run() reads multiple messages from the database server, some >may constitute changes and some may not. Changed the way change_seqno >is reset: if a message is not a change, reset change_seqno only to the >value before reading this message, not to the value before reading the >first message. >This will fix the return value in a scenario where some message was a >change and the last one wasn't. The new change_seqno will now be the >value after handling the message with the last change. > >Signed-off-by: Bodo Petermann <b.petermann@syseleven.de> >--- > Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
On 7/2/21 9:09 AM, aserdean@ovn.org wrote: > From: Alin Gabriel Serdean <aserdean@ovn.org> > >> Fix an issue where Idl.run() returned False even if there was a change. >> If Idl.run() reads multiple messages from the database server, some >> may constitute changes and some may not. Changed the way change_seqno >> is reset: if a message is not a change, reset change_seqno only to the >> value before reading this message, not to the value before reading the >> first message. >> This will fix the return value in a scenario where some message was a >> change and the last one wasn't. The new change_seqno will now be the >> value after handling the message with the last change. >> >> Signed-off-by: Bodo Petermann <b.petermann@syseleven.de> >> --- >> > Acked-by: Alin Gabriel Serdean <aserdean@ovn.org> Thanks! Applied and backported down to 2.13. Best regards, Ilya Maximets.
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 889cf3431..0fc2af3c2 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -246,6 +246,7 @@ class Idl(object): i = 0 while i < 50: i += 1 + previous_change_seqno = self.change_seqno if not self._session.is_connected(): break @@ -274,7 +275,7 @@ class Idl(object): if msg.params[0] == str(self.server_monitor_uuid): self.__parse_update(msg.params[1], OVSDB_UPDATE, tables=self.server_tables) - self.change_seqno = initial_change_seqno + self.change_seqno = previous_change_seqno if not self.__check_server_db(): self.force_reconnect() break @@ -317,7 +318,7 @@ class Idl(object): self.__error() break else: - self.change_seqno = initial_change_seqno + self.change_seqno = previous_change_seqno self.__send_monitor_request() elif (msg.type == ovs.jsonrpc.Message.T_REPLY and self._server_monitor_request_id is not None @@ -327,7 +328,7 @@ class Idl(object): self._server_monitor_request_id = None self.__parse_update(msg.result, OVSDB_UPDATE, tables=self.server_tables) - self.change_seqno = initial_change_seqno + self.change_seqno = previous_change_seqno if self.__check_server_db(): self.__send_monitor_request() self.__send_db_change_aware() @@ -341,7 +342,7 @@ class Idl(object): self.__error() break else: - self.change_seqno = initial_change_seqno + self.change_seqno = previous_change_seqno self.__send_monitor_request() elif (msg.type == ovs.jsonrpc.Message.T_REPLY and self._db_change_aware_request_id is not None @@ -377,7 +378,7 @@ class Idl(object): self.force_reconnect() break else: - self.change_seqno = initial_change_seqno + self.change_seqno = previous_change_seqno self.__send_monitor_request() elif (msg.type in (ovs.jsonrpc.Message.T_ERROR, ovs.jsonrpc.Message.T_REPLY)
Fix an issue where Idl.run() returned False even if there was a change. If Idl.run() reads multiple messages from the database server, some may constitute changes and some may not. Changed the way change_seqno is reset: if a message is not a change, reset change_seqno only to the value before reading this message, not to the value before reading the first message. This will fix the return value in a scenario where some message was a change and the last one wasn't. The new change_seqno will now be the value after handling the message with the last change. Signed-off-by: Bodo Petermann <b.petermann@syseleven.de> --- python/ovs/db/idl.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)