From 40c175fbe4fac31479beda212df59a9788c51787 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 30 Jul 2019 10:16:32 -0400 Subject: [PATCH] import sos-collector-1.7-2.el8_0 --- .gitignore | 2 +- .sos-collector.metadata | 2 +- SOURCES/sos-collector-local-pexpect.patch | 79 ------------------- .../sos-collector-nested-container-fix.patch | 59 ++++++++++++++ SOURCES/sos-collector-non-root-quote.patch | 26 ------ SOURCES/sos-collector-none-cluster-fix.patch | 30 +++++++ SOURCES/sos-collector-rhcos-image.patch | 29 +++++++ SOURCES/sos-collector-sat-support.patch | 70 ---------------- SPECS/sos-collector.spec | 57 +++++++++---- 9 files changed, 163 insertions(+), 191 deletions(-) delete mode 100644 SOURCES/sos-collector-local-pexpect.patch create mode 100644 SOURCES/sos-collector-nested-container-fix.patch delete mode 100644 SOURCES/sos-collector-non-root-quote.patch create mode 100644 SOURCES/sos-collector-none-cluster-fix.patch create mode 100644 SOURCES/sos-collector-rhcos-image.patch delete mode 100644 SOURCES/sos-collector-sat-support.patch diff --git a/.gitignore b/.gitignore index 7414830..8766018 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/sos-collector-1.6.tar.gz +SOURCES/sos-collector-1.7.tar.gz diff --git a/.sos-collector.metadata b/.sos-collector.metadata index 812d89a..76bf747 100644 --- a/.sos-collector.metadata +++ b/.sos-collector.metadata @@ -1 +1 @@ -61b7d707fb053f08678488c59c7d6826c4ae9d94 SOURCES/sos-collector-1.6.tar.gz +5a4f3d843e90ac35af70c2da2e1b18a62df036c3 SOURCES/sos-collector-1.7.tar.gz diff --git a/SOURCES/sos-collector-local-pexpect.patch b/SOURCES/sos-collector-local-pexpect.patch deleted file mode 100644 index 75bdf92..0000000 --- a/SOURCES/sos-collector-local-pexpect.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py -index 44d21c4..7fdb524 100644 ---- a/soscollector/sosnode.py -+++ b/soscollector/sosnode.py -@@ -26,7 +26,6 @@ import six - from distutils.version import LooseVersion - from pipes import quote - from soscollector.exceptions import * --from subprocess import Popen, PIPE - - - class SosNode(): -@@ -308,7 +307,7 @@ class SosNode(): - sudo or su - as appropriate and to input the password - force_local - force a command to run locally. Mainly used for scp. - ''' -- if not self.control_socket_exists: -+ if not self.control_socket_exists and not self.local: - self.log_debug('Control socket does not exist, attempting to ' - 're-create') - try: -@@ -333,42 +332,21 @@ class SosNode(): - get_pty = True - if not self.local and not force_local: - cmd = "%s %s" % (self.ssh_cmd, quote(cmd)) -- res = pexpect.spawn(cmd, encoding='utf-8') -- if need_root: -- if self.config['need_sudo']: -- res.sendline(self.config['sudo_pw']) -- if self.config['become_root']: -- res.sendline(self.config['root_password']) -- output = res.expect([pexpect.EOF, pexpect.TIMEOUT], -- timeout=timeout) -- if output == 0: -- out = res.before -- res.close() -- rc = res.exitstatus -- return {'status': rc, 'stdout': out} -- elif output == 1: -- raise CommandTimeoutException(cmd) -- else: -- try: -- proc = Popen(shlex.split(cmd), shell=get_pty, stdin=PIPE, -- stdout=PIPE, stderr=PIPE) -- if self.config['become_root'] and need_root: -- stdout, stderr = proc.communicate( -- input=self.config['root_password'] + '\n' -- ) -- elif self.config['need_sudo'] and need_root: -- stdout, stderr = proc.communicate( -- input=self.config['sudo_pw'] + '\n' -- ) -- else: -- stdout, stderr = proc.communicate() -- proc.wait() -- rc = proc.returncode -- return {'status': rc, 'stdout': stdout or stderr} -- except Exception as err: -- self.log_error("Exception while running command %s: %s" -- % (cmd, err)) -- raise -+ res = pexpect.spawn(cmd, encoding='utf-8') -+ if need_root: -+ if self.config['need_sudo']: -+ res.sendline(self.config['sudo_pw']) -+ if self.config['become_root']: -+ res.sendline(self.config['root_password']) -+ output = res.expect([pexpect.EOF, pexpect.TIMEOUT], -+ timeout=timeout) -+ if output == 0: -+ out = res.before -+ res.close() -+ rc = res.exitstatus -+ return {'status': rc, 'stdout': out} -+ elif output == 1: -+ raise CommandTimeoutException(cmd) - - def sosreport(self): - '''Run a sosreport on the node, then collect it''' diff --git a/SOURCES/sos-collector-nested-container-fix.patch b/SOURCES/sos-collector-nested-container-fix.patch new file mode 100644 index 0000000..0c33ae7 --- /dev/null +++ b/SOURCES/sos-collector-nested-container-fix.patch @@ -0,0 +1,59 @@ +From 0bc831a07be6ae837cb9029943c57255c47b647f Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Tue, 9 Apr 2019 12:59:03 -0400 +Subject: [PATCH] [sosnode] Don't create a container if we're in a container + +If sos-collector is being launched from a container on a containerized +host, we could potentially attempt to create a nested container. + +This change means we treat a sos-collector run that is already in a +container as a "normal" host and don't attempt the containerized bits. + +Signed-off-by: Jake Hunsaker +--- + soscollector/sosnode.py | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py +index a040244..405d05d 100644 +--- a/soscollector/sosnode.py ++++ b/soscollector/sosnode.py +@@ -68,10 +68,14 @@ class SosNode(): + self.connected = False + self.close_ssh_session() + return None ++ if self.local: ++ if self.check_in_container(): ++ self.host.containerized = False + self.log_debug("Host facts found to be %s" % + self.host.report_facts()) + self.get_hostname() +- self.create_sos_container() ++ if self.host.containerized: ++ self.create_sos_container() + self._load_sos_info() + + def _create_ssh_command(self): +@@ -84,6 +88,19 @@ class SosNode(): + return '{:<{}} : {}'.format(self._hostname, self.config['hostlen'] + 1, + msg) + ++ def check_in_container(self): ++ ''' ++ Tries to identify if we are currently running in a container or not. ++ ''' ++ if os.path.exists('/run/.containerenv'): ++ self.log_debug('Found /run/.containerenv. Running in container.') ++ return True ++ if os.environ.get('container') is not None: ++ self.log_debug("Found env var 'container'. Running in container") ++ return True ++ return False ++ ++ + def create_sos_container(self): + '''If the host is containerized, create the container we'll be using + ''' +-- +2.17.2 + diff --git a/SOURCES/sos-collector-non-root-quote.patch b/SOURCES/sos-collector-non-root-quote.patch deleted file mode 100644 index e5b89c1..0000000 --- a/SOURCES/sos-collector-non-root-quote.patch +++ /dev/null @@ -1,26 +0,0 @@ -From b69d2f8decf044d5ee4c97a580bc36bb1735b1c7 Mon Sep 17 00:00:00 2001 -From: Jake Hunsaker -Date: Fri, 21 Dec 2018 15:47:27 -0500 -Subject: [PATCH] [sosnode] Fix quoting for non-root su commands - -Signed-off-by: Jake Hunsaker ---- - soscollector/sosnode.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py -index 7fdb524..cfdb1e0 100644 ---- a/soscollector/sosnode.py -+++ b/soscollector/sosnode.py -@@ -154,7 +154,7 @@ class SosNode(): - here we prefix the command with the correct bits - ''' - if self.config['become_root']: -- return "su -c '%s'" % cmd -+ return "su -c %s" % quote(cmd) - if self.config['need_sudo']: - return "sudo -S %s" % cmd - return cmd --- -2.14.5 - diff --git a/SOURCES/sos-collector-none-cluster-fix.patch b/SOURCES/sos-collector-none-cluster-fix.patch new file mode 100644 index 0000000..8b7725e --- /dev/null +++ b/SOURCES/sos-collector-none-cluster-fix.patch @@ -0,0 +1,30 @@ +From a614ed8e5621f931d8ee76f1f59747a46144cb2d Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Thu, 4 Apr 2019 14:19:13 -0400 +Subject: [PATCH] [jbon] Fix typo in check_enabled() + +Fixes a typo in the check_enabled() method that could potentially +prevent sos-collector from correctly determining the cluster type on +python3 under certain circumstances. + +Signed-off-by: Jake Hunsaker +--- + soscollector/clusters/jbon.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/soscollector/clusters/jbon.py b/soscollector/clusters/jbon.py +index 28552ff..ea85ddf 100644 +--- a/soscollector/clusters/jbon.py ++++ b/soscollector/clusters/jbon.py +@@ -28,7 +28,7 @@ class jbon(Cluster): + def get_nodes(self): + return [] + +- def checK_enabled(self): ++ def check_enabled(self): + # This should never be called, but as insurance explicitly never + # allow this to be enabled via the determine_cluster() path + return False +-- +2.17.2 + diff --git a/SOURCES/sos-collector-rhcos-image.patch b/SOURCES/sos-collector-rhcos-image.patch new file mode 100644 index 0000000..2640115 --- /dev/null +++ b/SOURCES/sos-collector-rhcos-image.patch @@ -0,0 +1,29 @@ +From 6dafb42064b06a80720c6017e2576aea9a7211de Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Tue, 9 Apr 2019 13:00:44 -0400 +Subject: [PATCH] [redhat] Update RHCOS image + +Updates the image used by RHCOS nodes to be the rhel8 image instead +of rhel7. + +Signed-off-by: Jake Hunsaker +--- + soscollector/hosts/redhat.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/soscollector/hosts/redhat.py b/soscollector/hosts/redhat.py +index 33cec1f..774ecec 100644 +--- a/soscollector/hosts/redhat.py ++++ b/soscollector/hosts/redhat.py +@@ -66,7 +66,7 @@ class RedHatCoreOSHost(RedHatHost): + + containerized = True + container_runtime = 'podman' +- container_image = 'registry.redhat.io/rhel7/support-tools' ++ container_image = 'registry.redhat.io/rhel8/support-tools' + sos_path_strip = '/host' + + def check_enabled(self, rel_string): +-- +2.17.2 + diff --git a/SOURCES/sos-collector-sat-support.patch b/SOURCES/sos-collector-sat-support.patch deleted file mode 100644 index 93d85a6..0000000 --- a/SOURCES/sos-collector-sat-support.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 096ce477d314d47aa805fae585dc5aac17810d8f Mon Sep 17 00:00:00 2001 -From: Jake Hunsaker -Date: Fri, 28 Dec 2018 14:21:40 -0500 -Subject: [PATCH] [satellite] Add satellite a supported environment - -Adds a profile for Satellite 6. While not technically a cluster, Sat 6 -does have capsule servers that can be deployed concurrently to help with -load and distribution, so it still fits in with sos-collector's goal. - -Many thanks to Paul Dudley from Red Hat for assistance in providing a -test environment for this work and identifying the need. - -Signed-off-by: Jake Hunsaker ---- - soscollector/clusters/satellite.py | 43 ++++++++++++++++++++++++++++++++++++++ - 1 file changed, 43 insertions(+) - create mode 100644 soscollector/clusters/satellite.py - -diff --git a/soscollector/clusters/satellite.py b/soscollector/clusters/satellite.py -new file mode 100644 -index 0000000..ccdfefb ---- /dev/null -+++ b/soscollector/clusters/satellite.py -@@ -0,0 +1,43 @@ -+# Copyright Red Hat 2018, Jake Hunsaker -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+ -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License along -+# with this program; if not, write to the Free Software Foundation, Inc., -+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -+ -+from pipes import quote -+from soscollector.clusters import Cluster -+ -+ -+class satellite(Cluster): -+ """Red Hat Satellite 6""" -+ -+ packages = ('satellite', 'satellite-installer') -+ -+ def _psql_cmd(self, query): -+ _cmd = "su postgres -c %s" -+ _dbcmd = "psql foreman -c %s" -+ return _cmd % quote(_dbcmd % quote(query)) -+ -+ def get_nodes(self): -+ cmd = self._psql_cmd('select name from smart_proxies') -+ res = self.exec_master_cmd(cmd, need_root=True) -+ if res['status'] == 0: -+ idx = 2 -+ if 'could not change' in res['stdout']: -+ idx = 3 -+ nodes = [n.strip() for n in res['stdout'].splitlines()[idx:-1]] -+ return nodes -+ -+ def set_node_label(self, node): -+ if node.address == self.master.address: -+ return 'satellite' -+ return 'capsule' --- -2.14.5 - diff --git a/SPECS/sos-collector.spec b/SPECS/sos-collector.spec index b76ef3e..4901407 100644 --- a/SPECS/sos-collector.spec +++ b/SPECS/sos-collector.spec @@ -1,7 +1,7 @@ Summary: Capture sosreports from multiple nodes simultaneously Name: sos-collector -Version: 1.6 -Release: 4%{?dist} +Version: 1.7 +Release: 2%{?dist} Source0: http://people.redhat.com/jhunsake/sos-collector/%{name}-%{version}.tar.gz License: GPLv2 BuildArch: noarch @@ -10,16 +10,16 @@ Requires: sos >= 3.0 Obsoletes: clustersos < 1.2.2-2 Provides: clustersos = %{version}-%{release} -Patch0: sos-collector-local-pexpect.patch -Patch1: sos-collector-non-root-quote.patch -Patch2: sos-collector-sat-support.patch +Patch0: sos-collector-none-cluster-fix.patch +Patch1: sos-collector-nested-container-fix.patch +Patch2: sos-collector-rhcos-image.patch + %if 0%{?rhel} == 7 BuildRequires: python-devel -BuildRequires: python-setuptools -Requires: python2-futures +Requires: python-futures Requires: python-six -Requires: pexpect +Requires: python-pexpect %else BuildRequires: python3-devel BuildRequires: python3-six @@ -78,10 +78,39 @@ install -p -m644 man/en/sos-collector.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/ %license LICENSE %changelog -* Tue Jan 08 2019 Jake Hunsaker - 1.6-4 -- Adds support for Satellite deployments -- Fixes quoting for non-root local commands +* Thu Apr 11 2019 Jake Hunsaker - 1.7-2 +- Fix 'none' cluster type enablement +- Update RHCOS image to RHEL 8 version +- Fix execution from within a container -* Thu Dec 20 2018 Jake Hunsaker - 1.6-3 -- Initial RHEL 8 release based on upstream 1.6 -- Drops paramiko dependency in favor of OpenSSH ControlPersist +* Mon Apr 01 2019 Jake Hunsaker - 1.7-1 +- New upstream release +- Overhaul mechanism of execution of sosreport in containers +- Added RHCOS support +- Added a 'none' cluster type + +* Tue Dec 11 2018 Jake Hunsaker - 1.6-1 +- Drop paramiko dependency, use OpenSSH ControlPersist instead +- Layered cluster profiles can now accept base profile options +- Debian/Ubuntu hosts now supported + +* Thu Oct 11 2018 Jake Hunsaker - 1.5-1 +- New upstream release +- Resolves CVE-2018-14650 + +* Fri Jun 22 2018 Jake Hunsaker 1.4-1 +- New upstream release + +* Thu May 24 2018 Jake Hunsaker 1.3-3 +- Fix sos-collector archive organization +- Fix cluster option validation + +* Mon May 07 2018 Jake Hunsaker 1.3-2 +- Fix collection of sosreport tarballs + +* Fri Apr 27 2018 Jake Hunsaker 1.3-1 +- Reset versioning to continue from clustersos + +* Thu Apr 26 2018 Jake Hunsaker 1.0-1 +- Renamed project to sos-collector +- Moved github repo to sosreport org