From c9dd2823bbef382195beb62f05b242b8679c2655 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Wed, 23 Feb 2022 16:11:11 +0100 Subject: [PATCH] sos updates to RHEL9.0 Resolves: bz2043488 Signed-off-by: Pavel Moravec --- ...043488-ovn-proper-package-enablement.patch | 75 +++++++++++++++++++ sos.spec | 4 +- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/sos-bz2043488-ovn-proper-package-enablement.patch b/sos-bz2043488-ovn-proper-package-enablement.patch index 1f53ac6..16c48c4 100644 --- a/sos-bz2043488-ovn-proper-package-enablement.patch +++ b/sos-bz2043488-ovn-proper-package-enablement.patch @@ -100,6 +100,81 @@ index 0f947d4c5..2f0438df3 100644 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 +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 +--- + 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 Date: Tue, 15 Feb 2022 10:00:38 +0100 diff --git a/sos.spec b/sos.spec index 6c0ae31..e468c18 100644 --- a/sos.spec +++ b/sos.spec @@ -5,7 +5,7 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos Version: 4.2 -Release: 14%{?dist} +Release: 15%{?dist} Group: Applications/System Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz Source1: sos-audit-%{auditversion}.tgz @@ -147,7 +147,7 @@ of the system. Currently storage and filesystem commands are audited. %changelog -* Wed Feb 23 2022 Pavel Moravec = 4.2-14 +* Wed Feb 23 2022 Pavel Moravec = 4.2-15 - [sosnode] Handle downstream versioning for runtime option Resolves: bz2037350 - [options] Fix logging on plugopts in effective sos command