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

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