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

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