Blame SOURCES/sos-bz2004929-openvswitch-offline-analysis.patch

003633
From 3f0ec3e55e7dcec89dd7fad10084ea7f16178608 Mon Sep 17 00:00:00 2001
003633
From: Salvatore Daniele <sdaniele@redhat.com>
003633
Date: Tue, 7 Sep 2021 13:48:22 -0400
003633
Subject: [PATCH 1/2] [openvswitch] add ovs default OpenFlow protocols
003633
003633
ovs-vsctl list bridge can return an empty 'protocol' column even when
003633
there are OpenFlow protocols in place by default.
003633
003633
ovs-ofctl --version will return the range of supported ofp and should
003633
also be used to ensure flow information for relevant protocol versions
003633
is collected.
003633
003633
OpenFlow default versions:
003633
https://docs.openvswitch.org/en/latest/faq/openflow/
003633
003633
Signed-off-by: Salvatore Daniele <sdaniele@redhat.com>
003633
---
003633
 sos/report/plugins/openvswitch.py | 26 ++++++++++++++++++++++++++
003633
 1 file changed, 26 insertions(+)
003633
003633
diff --git a/sos/report/plugins/openvswitch.py b/sos/report/plugins/openvswitch.py
003633
index cd897db2..92cc7259 100644
003633
--- a/sos/report/plugins/openvswitch.py
003633
+++ b/sos/report/plugins/openvswitch.py
003633
@@ -206,6 +206,7 @@ class OpenVSwitch(Plugin):
003633
 
003633
         # Gather additional output for each OVS bridge on the host.
003633
         br_list_result = self.collect_cmd_output("ovs-vsctl -t 5 list-br")
003633
+        ofp_ver_result = self.collect_cmd_output("ovs-ofctl -t 5 --version")
003633
         if br_list_result['status'] == 0:
003633
             for br in br_list_result['output'].splitlines():
003633
                 self.add_cmd_output([
003633
@@ -232,6 +233,16 @@ class OpenVSwitch(Plugin):
003633
                     "OpenFlow15"
003633
                 ]
003633
 
003633
+                # Flow protocol hex identifiers
003633
+                ofp_versions = {
003633
+                    0x01: "OpenFlow10",
003633
+                    0x02: "OpenFlow11",
003633
+                    0x03: "OpenFlow12",
003633
+                    0x04: "OpenFlow13",
003633
+                    0x05: "OpenFlow14",
003633
+                    0x06: "OpenFlow15",
003633
+                }
003633
+
003633
                 # List protocols currently in use, if any
003633
                 ovs_list_bridge_cmd = "ovs-vsctl -t 5 list bridge %s" % br
003633
                 br_info = self.collect_cmd_output(ovs_list_bridge_cmd)
003633
@@ -242,6 +253,21 @@ class OpenVSwitch(Plugin):
003633
                         br_protos_ln = line[line.find("[")+1:line.find("]")]
003633
                         br_protos = br_protos_ln.replace('"', '').split(", ")
003633
 
003633
+                # If 'list bridge' yeilded no protocols, use the range of
003633
+                # protocols enabled by default on this version of ovs.
003633
+                if br_protos == [''] and ofp_ver_result['output']:
003633
+                    ofp_version_range = ofp_ver_result['output'].splitlines()
003633
+                    ver_range = []
003633
+
003633
+                    for line in ofp_version_range:
003633
+                        if "OpenFlow versions" in line:
003633
+                            v = line.split("OpenFlow versions ")[1].split(":")
003633
+                            ver_range = range(int(v[0], 16), int(v[1], 16)+1)
003633
+
003633
+                    for protocol in ver_range:
003633
+                        if protocol in ofp_versions:
003633
+                            br_protos.append(ofp_versions[protocol])
003633
+
003633
                 # Collect flow information for relevant protocol versions only
003633
                 for flow in flow_versions:
003633
                     if flow in br_protos:
003633
-- 
003633
2.31.1
003633
003633
003633
From 5a006024f730213a726c70e82c5ecd2daf685b2b Mon Sep 17 00:00:00 2001
003633
From: Salvatore Daniele <sdaniele@redhat.com>
003633
Date: Tue, 7 Sep 2021 14:17:19 -0400
003633
Subject: [PATCH 2/2] [openvswitch] add commands for offline analysis
003633
003633
Replicas of ovs-vswitchd and ovsdb-server can be recreated offline
003633
using flow, group, and tlv dumps, and ovs conf.db. This allows for
003633
offline anaylsis and the use of tools such as ovs-appctl
003633
ofproto/trace and ovs-ofctl for debugging.
003633
003633
This patch ensures this information is available in the sos report.
003633
The db is copied rather than collected using ovsdb-client list dump
003633
for two reasons:
003633
003633
ovsdb-client requires interacting with the ovsdb-server which could
003633
take it 'down' for some time, and impact large, busy clusters.
003633
003633
The list-dump is not in a format that can be used to restore the db
003633
offline. All of the information in the list dump is available and more
003633
by copying the db.
003633
003633
Signed-off-by: Salvatore Daniele <sdaniele@redhat.com>
003633
---
003633
 sos/report/plugins/openvswitch.py | 12 ++++++++++--
003633
 sos/report/plugins/ovn_central.py |  1 +
003633
 2 files changed, 11 insertions(+), 2 deletions(-)
003633
003633
diff --git a/sos/report/plugins/openvswitch.py b/sos/report/plugins/openvswitch.py
003633
index 92cc7259..003596c6 100644
003633
--- a/sos/report/plugins/openvswitch.py
003633
+++ b/sos/report/plugins/openvswitch.py
003633
@@ -75,12 +75,19 @@ class OpenVSwitch(Plugin):
003633
             "/run/openvswitch/ovs-monitor-ipsec.pid"
003633
         ])
003633
 
003633
+        self.add_copy_spec([
003633
+            path_join('/usr/local/etc/openvswitch', 'conf.db'),
003633
+            path_join('/etc/openvswitch', 'conf.db'),
003633
+            path_join('/var/lib/openvswitch', 'conf.db'),
003633
+        ])
003633
+        ovs_dbdir = environ.get('OVS_DBDIR')
003633
+        if ovs_dbdir:
003633
+            self.add_copy_spec(path_join(ovs_dbdir, 'conf.db'))
003633
+
003633
         self.add_cmd_output([
003633
             # The '-t 5' adds an upper bound on how long to wait to connect
003633
             # to the Open vSwitch server, avoiding hangs when running sos.
003633
             "ovs-vsctl -t 5 show",
003633
-            # Gather the database.
003633
-            "ovsdb-client -f list dump",
003633
             # List the contents of important runtime directories
003633
             "ls -laZ /run/openvswitch",
003633
             "ls -laZ /dev/hugepages/",
003633
@@ -276,6 +283,7 @@ class OpenVSwitch(Plugin):
003633
                             "ovs-ofctl -O %s dump-groups %s" % (flow, br),
003633
                             "ovs-ofctl -O %s dump-group-stats %s" % (flow, br),
003633
                             "ovs-ofctl -O %s dump-flows %s" % (flow, br),
003633
+                            "ovs-ofctl -O %s dump-tlv-map %s" % (flow, br),
003633
                             "ovs-ofctl -O %s dump-ports-desc %s" % (flow, br)
003633
                         ])
003633
 
003633
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
003633
index a4c483a9..d6647aad 100644
003633
--- a/sos/report/plugins/ovn_central.py
003633
+++ b/sos/report/plugins/ovn_central.py
003633
@@ -138,6 +138,7 @@ class OVNCentral(Plugin):
003633
                 os.path.join('/usr/local/etc/openvswitch', dbfile),
003633
                 os.path.join('/etc/openvswitch', dbfile),
003633
                 os.path.join('/var/lib/openvswitch', dbfile),
003633
+                os.path.join('/var/lib/ovn/etc', dbfile),
003633
             ])
003633
             if ovs_dbdir:
003633
                 self.add_copy_spec(os.path.join(ovs_dbdir, dbfile))
003633
-- 
003633
2.31.1
003633