diff mbox series

[ovs-dev,7/7] python: idl: Allow retry even when using a single remote.

Message ID 20210501005548.3071269-8-i.maximets@ovn.org
State Accepted
Headers show
Series OVSDB 2-Tier deployment. | expand

Commit Message

Ilya Maximets May 1, 2021, 12:55 a.m. UTC
As described in commit [1], it's possible that remote IP is backed by
a load-balancer and re-connection to this same IP will lead to
connection to a different server.  This case is supported for C version
of IDL and should be supported in a same way for python implementation.

[1] ca367fa5f8bb ("ovsdb-idl.c: Allows retry even when using a single remote.")

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 python/ovs/db/idl.py   |  3 +--
 tests/ovsdb-cluster.at | 14 ++++++++++++--
 tests/test-ovsdb.py    |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

Comments

Dumitru Ceara May 10, 2021, 12:34 p.m. UTC | #1
On 5/1/21 2:55 AM, Ilya Maximets wrote:
> As described in commit [1], it's possible that remote IP is backed by
> a load-balancer and re-connection to this same IP will lead to
> connection to a different server.  This case is supported for C version
> of IDL and should be supported in a same way for python implementation.
> 
> [1] ca367fa5f8bb ("ovsdb-idl.c: Allows retry even when using a single remote.")
> 
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>
Ilya Maximets June 11, 2021, 5:10 a.m. UTC | #2
On 5/10/21 2:34 PM, Dumitru Ceara wrote:
> On 5/1/21 2:55 AM, Ilya Maximets wrote:
>> As described in commit [1], it's possible that remote IP is backed by
>> a load-balancer and re-connection to this same IP will lead to
>> connection to a different server.  This case is supported for C version
>> of IDL and should be supported in a same way for python implementation.
>>
>> [1] ca367fa5f8bb ("ovsdb-idl.c: Allows retry even when using a single remote.")
>>
>> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
>> ---
> 
> Looks good to me, thanks!
> 
> Acked-by: Dumitru Ceara <dceara@redhat.com>
> 

Thanks for review!

I applied this one patch to master since it's a separate change that
is not really related to the rest of the series.

Other patches will of the set will be superseded or dropped in v2.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index f8474d8de..65c1c787b 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -779,8 +779,7 @@  class Idl(object):
                 vlog.info('%s: replication server is disconnected from the '
                           'replication source; trying another server'
                           % session_name)
-        elif (database.model == CLUSTERED and
-              self._session.get_num_of_remotes() > 1):
+        elif database.model == CLUSTERED:
             if not database.schema:
                 vlog.info('%s: clustered database server has not yet joined '
                           'cluster; trying another server' % session_name)
diff --git a/tests/ovsdb-cluster.at b/tests/ovsdb-cluster.at
index abf57a6b9..385415afe 100644
--- a/tests/ovsdb-cluster.at
+++ b/tests/ovsdb-cluster.at
@@ -137,17 +137,26 @@  ovsdb_test_cluster_disconnect () {
         cleanup="$cleanup ${target}_backup"
     fi
 
-    test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -v -t10 idl unix:s${client_target}.ovsdb '[["idltest",
+    txn='[["idltest",
           {"op": "wait",
            "table": "simple",
            "where": [["i", "==", 1]],
            "columns": ["i"],
            "until": "==",
-           "rows": [{"i": 1}]}]]' > test-ovsdb.log 2>&1 &
+           "rows": [{"i": 1}]}]]'
+
+    test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -v -t10 idl \
+               unix:s${client_target}.ovsdb "$txn" > test-ovsdb.log 2>&1 &
     echo $! > test-ovsdb.pid
 
     OVS_WAIT_UNTIL([grep "000: table simple: i=1" test-ovsdb.log])
 
+    $PYTHON3 $srcdir/test-ovsdb.py -t10 idl $abs_srcdir/idltest.ovsschema \
+               unix:s${client_target}.ovsdb "$txn" > test-ovsdb-py.log 2>&1 &
+    echo $! > test-ovsdb-py.pid
+
+    OVS_WAIT_UNTIL([grep "000: table simple: i=1" test-ovsdb-py.log])
+
     # Start collecting raft_is_connected logs for $target before shutting down
     # any servers.
     tail -f s$target.log > raft_is_connected.log &
@@ -160,6 +169,7 @@  ovsdb_test_cluster_disconnect () {
 
     # The test-ovsdb should detect the disconnect and retry.
     OVS_WAIT_UNTIL([grep disconnect test-ovsdb.log])
+    OVS_WAIT_UNTIL([grep disconnect test-ovsdb-py.log])
 
     # The $target debug log should show raft_is_connected: false.
     OVS_WAIT_UNTIL([grep "raft_is_connected: false" raft_is_connected.log])
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index 72a319123..5bc0bf681 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -651,7 +651,7 @@  def do_idl(schema_file, remote, *commands):
         commands = commands[1:]
     else:
         schema_helper.register_all()
-    idl = ovs.db.idl.Idl(remote, schema_helper)
+    idl = ovs.db.idl.Idl(remote, schema_helper, leader_only=False)
     if "simple3" in idl.tables:
         idl.index_create("simple3", "simple3_by_name")