sos/SOURCES/sos-bz2042966-ovn-proper-package-enablement.patch
2022-03-29 18:00:24 +00:00

253 lines
9.6 KiB
Diff

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