Blame SOURCES/sos-bz2043488-ovn-proper-package-enablement.patch

8f6d4d
From 210b83e1d1164d29b1f6198675b8b596c4af8336 Mon Sep 17 00:00:00 2001
8f6d4d
From: Daniel Alvarez Sanchez <dalvarez@redhat.com>
8f6d4d
Date: Thu, 20 Jan 2022 12:58:44 +0100
8f6d4d
Subject: [PATCH] [ovn_central] Account for Red Hat ovn package naming
8f6d4d
8f6d4d
Previous ovn packages were 'ovn2xxx' and now they have
8f6d4d
been renamed to 'ovn-2xxx'. This causes sos tool to not
8f6d4d
recognize that the packages are installed and it won't
8f6d4d
collect the relevant data.
8f6d4d
8f6d4d
This patch is changing the match to be compatible
8f6d4d
with the previous and newer naming conventions.
8f6d4d
8f6d4d
Signed-off-by: Daniel Alvarez Sanchez <dalvarez@redhat.com>
8f6d4d
---
8f6d4d
 sos/report/plugins/ovn_central.py | 2 +-
8f6d4d
 sos/report/plugins/ovn_host.py    | 2 +-
8f6d4d
 2 files changed, 2 insertions(+), 2 deletions(-)
8f6d4d
8f6d4d
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
8f6d4d
index ddbf288da..0f947d4c5 100644
8f6d4d
--- a/sos/report/plugins/ovn_central.py
8f6d4d
+++ b/sos/report/plugins/ovn_central.py
8f6d4d
@@ -147,7 +147,7 @@ def setup(self):
8f6d4d
 
8f6d4d
 class RedHatOVNCentral(OVNCentral, RedHatPlugin):
8f6d4d
 
8f6d4d
-    packages = ('openvswitch-ovn-central', 'ovn2.*-central', )
8f6d4d
+    packages = ('openvswitch-ovn-central', 'ovn.*-central', )
8f6d4d
     ovn_sbdb_sock_path = '/var/run/openvswitch/ovnsb_db.ctl'
8f6d4d
 
8f6d4d
 
8f6d4d
diff --git a/sos/report/plugins/ovn_host.py b/sos/report/plugins/ovn_host.py
8f6d4d
index 78604a15a..25c38cccc 100644
8f6d4d
--- a/sos/report/plugins/ovn_host.py
8f6d4d
+++ b/sos/report/plugins/ovn_host.py
8f6d4d
@@ -55,7 +55,7 @@ def check_enabled(self):
8f6d4d
 
8f6d4d
 class RedHatOVNHost(OVNHost, RedHatPlugin):
8f6d4d
 
8f6d4d
-    packages = ('openvswitch-ovn-host', 'ovn2.*-host', )
8f6d4d
+    packages = ('openvswitch-ovn-host', 'ovn.*-host', )
8f6d4d
 
8f6d4d
 
8f6d4d
 class DebianOVNHost(OVNHost, DebianPlugin, UbuntuPlugin):
07d560
From 21fc376d97a5f74743e2b7cf7069349e874b979e Mon Sep 17 00:00:00 2001
07d560
From: Hemanth Nakkina <hemanth.nakkina@canonical.com>
07d560
Date: Fri, 4 Feb 2022 07:57:59 +0530
07d560
Subject: [PATCH] [ovn-central] collect NB/SB ovsdb-server cluster status
07d560
07d560
Add commands to collect cluster status of Northbound and
07d560
Southbound ovsdb servers.
07d560
07d560
Resolves: #2840
07d560
07d560
Signed-off-by: Hemanth Nakkina hemanth.nakkina@canonical.com
07d560
---
07d560
 sos/report/plugins/ovn_central.py | 13 ++++++++++++-
07d560
 1 file changed, 12 insertions(+), 1 deletion(-)
07d560
07d560
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
07d560
index 0f947d4c5..2f0438df3 100644
07d560
--- a/sos/report/plugins/ovn_central.py
07d560
+++ b/sos/report/plugins/ovn_central.py
07d560
@@ -84,6 +84,14 @@ def setup(self):
07d560
         else:
07d560
             self.add_copy_spec("/var/log/ovn/*.log")
07d560
 
07d560
+        # ovsdb nb/sb cluster status commands
07d560
+        ovsdb_cmds = [
07d560
+            'ovs-appctl -t {} cluster/status OVN_Northbound'.format(
07d560
+                self.ovn_nbdb_sock_path),
07d560
+            'ovs-appctl -t {} cluster/status OVN_Southbound'.format(
07d560
+                self.ovn_sbdb_sock_path),
07d560
+        ]
07d560
+
07d560
         # Some user-friendly versions of DB output
07d560
         nbctl_cmds = [
07d560
             'ovn-nbctl show',
07d560
@@ -109,7 +117,8 @@ def setup(self):
07d560
 
07d560
         self.add_database_output(nb_tables, nbctl_cmds, 'ovn-nbctl')
07d560
 
07d560
-        cmds = nbctl_cmds
07d560
+        cmds = ovsdb_cmds
07d560
+        cmds += nbctl_cmds
07d560
 
07d560
         # Can only run sbdb commands if we are the leader
07d560
         co = {'cmd': "ovs-appctl -t {} cluster/status OVN_Southbound".
07d560
@@ -148,10 +157,12 @@ def setup(self):
07d560
 class RedHatOVNCentral(OVNCentral, RedHatPlugin):
07d560
 
07d560
     packages = ('openvswitch-ovn-central', 'ovn.*-central', )
07d560
+    ovn_nbdb_sock_path = '/var/run/openvswitch/ovnnb_db.ctl'
07d560
     ovn_sbdb_sock_path = '/var/run/openvswitch/ovnsb_db.ctl'
07d560
 
07d560
 
07d560
 class DebianOVNCentral(OVNCentral, DebianPlugin, UbuntuPlugin):
07d560
 
07d560
     packages = ('ovn-central', )
07d560
+    ovn_nbdb_sock_path = '/var/run/ovn/ovnnb_db.ctl'
07d560
     ovn_sbdb_sock_path = '/var/run/ovn/ovnsb_db.ctl'
07d560
From d0f9d507b0ec63c9e8f3e5d7b6507d9d0f97c038 Mon Sep 17 00:00:00 2001
07d560
From: Jake Hunsaker <jhunsake@redhat.com>
07d560
Date: Tue, 15 Feb 2022 16:24:47 -0500
07d560
Subject: [PATCH] [runtimes] Allow container IDs to be used with
07d560
 `container_exists()`
07d560
07d560
As container runtimes can interchange container names and container IDs,
07d560
sos should also allow the use of container IDs when checking for the
07d560
presence of a given container.
07d560
07d560
In particular, this change unblocks the use of `Plugin.exec_cmd()` when
07d560
used in conjunction with `Plugin.get_container_by_name()` to pick a
07d560
container based on a provided regex that the container name may match.
07d560
07d560
Related: #2856
07d560
07d560
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
07d560
---
07d560
 sos/policies/runtimes/__init__.py | 17 +++++++++++++++++
07d560
 sos/report/plugins/__init__.py    |  6 +++---
07d560
 2 files changed, 20 insertions(+), 3 deletions(-)
07d560
07d560
diff --git a/sos/policies/runtimes/__init__.py b/sos/policies/runtimes/__init__.py
07d560
index 5ac673544..d28373496 100644
07d560
--- a/sos/policies/runtimes/__init__.py
07d560
+++ b/sos/policies/runtimes/__init__.py
07d560
@@ -147,6 +147,23 @@ def get_volumes(self):
07d560
                     vols.append(ent[-1])
07d560
         return vols
07d560
 
07d560
+    def container_exists(self, container):
07d560
+        """Check if a given container ID or name exists on the system from the
07d560
+        perspective of the container runtime.
07d560
+
07d560
+        Note that this will only check _running_ containers
07d560
+
07d560
+        :param container:       The name or ID of the container
07d560
+        :type container:        ``str``
07d560
+
07d560
+        :returns:               True if the container exists, else False
07d560
+        :rtype:                 ``bool``
07d560
+        """
07d560
+        for _contup in self.containers:
07d560
+            if container in _contup:
07d560
+                return True
07d560
+        return False
07d560
+
07d560
     def fmt_container_cmd(self, container, cmd, quotecmd):
07d560
         """Format a command to run inside a container using the runtime
07d560
 
07d560
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
07d560
index 2988be089..cc5cb65bc 100644
07d560
--- a/sos/report/plugins/__init__.py
07d560
+++ b/sos/report/plugins/__init__.py
07d560
@@ -2593,7 +2593,7 @@ def container_exists(self, name):
07d560
         """If a container runtime is present, check to see if a container with
07d560
         a given name is currently running
07d560
 
07d560
-        :param name:    The name of the container to check presence of
07d560
+        :param name:    The name or ID of the container to check presence of
07d560
         :type name: ``str``
07d560
 
07d560
         :returns: ``True`` if `name` exists, else ``False``
07d560
@@ -2601,8 +2601,8 @@ def container_exists(self, name):
07d560
         """
07d560
         _runtime = self._get_container_runtime()
07d560
         if _runtime is not None:
07d560
-            con = _runtime.get_container_by_name(name)
07d560
-            return con is not None
07d560
+            return (_runtime.container_exists(name) or
07d560
+                    _runtime.get_container_by_name(name) is not None)
07d560
         return False
07d560
 
07d560
     def get_all_containers_by_regex(self, regex, get_all=False):
07d560
07d560
From de9b020a72d1ceda39587db4c6d5acf72cd90da2 Mon Sep 17 00:00:00 2001
07d560
From: Fernando Royo <froyo@redhat.com>
07d560
Date: Tue, 15 Feb 2022 10:00:38 +0100
07d560
Subject: [PATCH] [ovn_central] Rename container responsable of Red Hat
07d560
 ovn_central plugin
07d560
07d560
ovn_central plugin is running by container with
07d560
name 'ovn-dbs-bundle*', a typo has been identified and
07d560
this cause plugin ovn_central not enabled by default as it
07d560
does not recognize any container responsible of this.
07d560
07d560
This patch fix this container name match, searching schema db
07d560
keeping backward compatibility with openvswitch.
07d560
---
07d560
 sos/report/plugins/ovn_central.py | 23 ++++++++++++-----------
07d560
 1 file changed, 12 insertions(+), 11 deletions(-)
07d560
07d560
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
07d560
index 2f0438df..2f34bff0 100644
07d560
--- a/sos/report/plugins/ovn_central.py
07d560
+++ b/sos/report/plugins/ovn_central.py
07d560
@@ -24,7 +24,7 @@ class OVNCentral(Plugin):
07d560
     short_desc = 'OVN Northd'
07d560
     plugin_name = "ovn_central"
07d560
     profiles = ('network', 'virt')
07d560
-    containers = ('ovs-db-bundle.*',)
07d560
+    containers = ('ovn-dbs-bundle.*',)
07d560
 
07d560
     def get_tables_from_schema(self, filename, skip=[]):
07d560
         if self._container_name:
07d560
@@ -66,7 +66,7 @@ class OVNCentral(Plugin):
07d560
             cmds.append('%s list %s' % (ovn_cmd, table))
07d560
 
07d560
     def setup(self):
07d560
-        self._container_name = self.get_container_by_name('ovs-dbs-bundle.*')
07d560
+        self._container_name = self.get_container_by_name(self.containers[0])
07d560
 
07d560
         ovs_rundir = os.environ.get('OVS_RUNDIR')
07d560
         for pidfile in ['ovnnb_db.pid', 'ovnsb_db.pid', 'ovn-northd.pid']:
07d560
@@ -110,12 +110,11 @@ class OVNCentral(Plugin):
07d560
             'ovn-sbctl get-connection',
07d560
         ]
07d560
 
07d560
-        schema_dir = '/usr/share/openvswitch'
07d560
-
07d560
-        nb_tables = self.get_tables_from_schema(self.path_join(
07d560
-            schema_dir, 'ovn-nb.ovsschema'))
07d560
-
07d560
-        self.add_database_output(nb_tables, nbctl_cmds, 'ovn-nbctl')
07d560
+        # backward compatibility
07d560
+        for path in ['/usr/share/openvswitch', '/usr/share/ovn']:
07d560
+            nb_tables = self.get_tables_from_schema(self.path_join(
07d560
+                path, 'ovn-nb.ovsschema'))
07d560
+            self.add_database_output(nb_tables, nbctl_cmds, 'ovn-nbctl')
07d560
 
07d560
         cmds = ovsdb_cmds
07d560
         cmds += nbctl_cmds
07d560
@@ -125,9 +124,11 @@ class OVNCentral(Plugin):
07d560
               format(self.ovn_sbdb_sock_path),
07d560
               "output": "Leader: self"}
07d560
         if self.test_predicate(self, pred=SoSPredicate(self, cmd_outputs=co)):
07d560
-            sb_tables = self.get_tables_from_schema(self.path_join(
07d560
-                schema_dir, 'ovn-sb.ovsschema'), ['Logical_Flow'])
07d560
-            self.add_database_output(sb_tables, sbctl_cmds, 'ovn-sbctl')
07d560
+            # backward compatibility
07d560
+            for path in ['/usr/share/openvswitch', '/usr/share/ovn']:
07d560
+                sb_tables = self.get_tables_from_schema(self.path_join(
07d560
+                    path, 'ovn-sb.ovsschema'), ['Logical_Flow'])
07d560
+                self.add_database_output(sb_tables, sbctl_cmds, 'ovn-sbctl')
07d560
             cmds += sbctl_cmds
07d560
 
07d560
         # If OVN is containerized, we need to run the above commands inside
07d560
-- 
07d560
2.34.1
07d560