summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2021-06-10 18:47:14 +0200
committerIlya Maximets <i.maximets@ovn.org>2021-06-11 01:11:57 +0200
commitc5a58ec155d89addeaff73cef95dc5f0dce2ef97 (patch)
tree92c6896ba3a687a8d3408751cb623d884cc3ed57
parent04f8881f5795483968987d6d7e8b522c11f2d06e (diff)
downloadopenvswitch-c5a58ec155d89addeaff73cef95dc5f0dce2ef97.tar.gz
python: idl: Allow retry even when using a single remote.
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> Acked-by: Dumitru Ceara <dceara@redhat.com>
-rw-r--r--python/ovs/db/idl.py3
-rw-r--r--tests/ovsdb-cluster.at14
-rw-r--r--tests/test-ovsdb.py2
3 files changed, 14 insertions, 5 deletions
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 4226d1cb2..889cf3431 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -777,8 +777,7 @@ class Idl(object):
% (session_name, self._db.name))
return False
- if (database.model == CLUSTERED and
- self._session.get_num_of_remotes() > 1):
+ if 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 cf43e9cf8..fc6253cfe 100644
--- a/tests/ovsdb-cluster.at
+++ b/tests/ovsdb-cluster.at
@@ -119,17 +119,26 @@ ovsdb_test_cluster_disconnect () {
# Connect to $target. Use "wait" to trigger a non-op transaction so
# that test-ovsdb will not quit.
- test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -v -t10 idl unix:s$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$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$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 &
@@ -142,6 +151,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")