diff mbox series

[ovs-dev] ovn-detrace: Support connecting to NB and SB raft followers

Message ID 20230110124448.336468-1-dceara@redhat.com
State Accepted
Headers show
Series [ovs-dev] ovn-detrace: Support connecting to NB and SB raft followers | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Dumitru Ceara Jan. 10, 2023, 12:44 p.m. UTC
From: "jun.gu" <jun.gu@easystack.cn>

Provide --no-leader-only option to support connecting to NB and SB raft
followers. By default, the leader is connected for NB and SB.

Signed-off-by: Jun Gu <jun.gu@easystack.cn>
---
 utilities/ovn-detrace.1.in  |  4 ++++
 utilities/ovn_detrace.py.in | 21 +++++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

Comments

Dumitru Ceara Jan. 10, 2023, 12:47 p.m. UTC | #1
On 1/10/23 13:44, Dumitru Ceara wrote:
> From: "jun.gu" <jun.gu@easystack.cn>
> 
> Provide --no-leader-only option to support connecting to NB and SB raft
> followers. By default, the leader is connected for NB and SB.
> 
> Signed-off-by: Jun Gu <jun.gu@easystack.cn>
> ---

Submitted-at: https://github.com/ovn-org/ovn/pull/171
0-day Robot Jan. 10, 2023, 12:59 p.m. UTC | #2
Bleep bloop.  Greetings Dumitru Ceara, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author jun.gu <jun.gu@easystack.cn> needs to sign off.
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Jun Gu <jun.gu@easystack.cn>
Lines checked: 104, Warnings: 1, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Dumitru Ceara Jan. 10, 2023, 1:33 p.m. UTC | #3
On 1/10/23 13:47, Dumitru Ceara wrote:
> On 1/10/23 13:44, Dumitru Ceara wrote:
>> From: "jun.gu" <jun.gu@easystack.cn>
>>
>> Provide --no-leader-only option to support connecting to NB and SB raft
>> followers. By default, the leader is connected for NB and SB.
>>
>> Signed-off-by: Jun Gu <jun.gu@easystack.cn>
>> ---
> 
> Submitted-at: https://github.com/ovn-org/ovn/pull/171

I went ahead and pushed this change to the main branch.

Thanks!
diff mbox series

Patch

diff --git a/utilities/ovn-detrace.1.in b/utilities/ovn-detrace.1.in
index 7feba07662..a8d94c93de 100644
--- a/utilities/ovn-detrace.1.in
+++ b/utilities/ovn-detrace.1.in
@@ -39,6 +39,10 @@  environments.
 Also decode flow information (like OVS ofport) from the flows by connecting
 to the OVS DB.
 .
+.IP "\fB\-\-no-leader-only\fR"
+Connect to any cluster member, not just the leader. The option works for
+OVN Southbound DB and OVN Northbound DB.
+.
 .IP "\fB\-\-ovsdb=\fIserver\fR"
 The OVS DB remote to contact if \fB\-\-ovs\fR is present.  If the
 \fBOVS_RUNDIR\fR environment variable is set, its value is used as the
diff --git a/utilities/ovn_detrace.py.in b/utilities/ovn_detrace.py.in
index dac4a1cbf7..364f11a71d 100755
--- a/utilities/ovn_detrace.py.in
+++ b/utilities/ovn_detrace.py.in
@@ -50,6 +50,7 @@  The following options are also available:
   --ovnsb=DATABASE            use DATABASE as southbound DB
   --ovnnb=DATABASE            use DATABASE as northbound DB
   --ovsdb=DATABASE            use DATABASE as OVS DB
+  --no-leader-only            accept any cluster member, not just the leader
   -p, --private-key=FILE      file with private key
   -c, --certificate=FILE      file with certificate for private key
   -C, --ca-cert=FILE          file with peer CA certificate\
@@ -90,12 +91,12 @@  class OVSDB(object):
             if time.time() >= stop:
                 raise Exception('Retry Timeout')
 
-    def __init__(self, remote, schema_name):
+    def __init__(self, remote, schema_name, leader_only=True):
         self.remote = remote
         self._txn = None
         schema = self._get_schema(schema_name)
         schema.register_all()
-        self._idl_conn = idl.Idl(remote, schema)
+        self._idl_conn = idl.Idl(remote, schema, leader_only=leader_only)
         OVSDB.wait_for_db_change(self._idl_conn)  # Initial Sync with DB
 
     def _get_schema(self, schema_name):
@@ -411,6 +412,7 @@  def main():
     try:
         options, args = getopt.gnu_getopt(sys.argv[1:], 'hVp:c:C:',
                                           ['help', 'version', 'ovs',
+                                           'no-leader-only',
                                            'ovnsb=', 'ovnnb=', 'ovsdb=',
                                            'private-key=', 'certificate=',
                                            'ca-cert='])
@@ -418,10 +420,11 @@  def main():
         sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
         sys.exit(1)
 
-    ovnsb_db = None
-    ovnnb_db = None
-    ovs_db   = None
-    ovs      = False
+    ovnsb_db    = None
+    ovnnb_db    = None
+    ovs_db      = None
+    ovs         = False
+    leader_only = True
 
     ssl_pk      = None
     ssl_cert    = None
@@ -446,6 +449,8 @@  def main():
             ssl_ca_cert = value
         elif key in ['--ovs']:
             ovs = True
+        elif key in ['--no-leader-only']:
+            leader_only = False
         else:
             sys.exit(0)
 
@@ -483,8 +488,8 @@  def main():
     if ovs and not ovs_db:
         ovs_db = 'unix:%s/db.sock' % ovs_rundir
 
-    ovsdb_ovnsb = OVSDB(ovnsb_db, 'OVN_Southbound')
-    ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound')
+    ovsdb_ovnsb = OVSDB(ovnsb_db, 'OVN_Southbound', leader_only=leader_only)
+    ovsdb_ovnnb = OVSDB(ovnnb_db, 'OVN_Northbound', leader_only=leader_only)
 
     printer = Printer()
     cookie_handlers = get_cookie_handlers(ovsdb_ovnnb, ovsdb_ovnsb, printer)