From 8f0bb7816c83c2005ef5dd20a64d307b025cd34e Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 02 2019 00:42:38 +0000 Subject: import sos-collector-1.7-4.el8 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8766018 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/sos-collector-1.7.tar.gz diff --git a/.sos-collector.metadata b/.sos-collector.metadata new file mode 100644 index 0000000..76bf747 --- /dev/null +++ b/.sos-collector.metadata @@ -0,0 +1 @@ +5a4f3d843e90ac35af70c2da2e1b18a62df036c3 SOURCES/sos-collector-1.7.tar.gz 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-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-pexpect.patch b/SOURCES/sos-collector-pexpect.patch new file mode 100644 index 0000000..ca55865 --- /dev/null +++ b/SOURCES/sos-collector-pexpect.patch @@ -0,0 +1,30 @@ +From 76ca28dc5ce222d24086b387a448ceeb53055e4b Mon Sep 17 00:00:00 2001 +From: Jake Hunsaker +Date: Wed, 15 May 2019 16:21:01 -0400 +Subject: [PATCH] [sosnode] Properly quote commands that need a pty + +When we run locally and need a pty, we need to quote the command and +launch it in a bash shell to function correctly with pexpect.spawn(). + +Signed-off-by: Jake Hunsaker +--- + soscollector/sosnode.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py +index 6c01471..fc42b94 100644 +--- a/soscollector/sosnode.py ++++ b/soscollector/sosnode.py +@@ -366,6 +366,9 @@ class SosNode(): + get_pty = True + if not self.local and not force_local: + cmd = "%s %s" % (self.ssh_cmd, quote(cmd)) ++ else: ++ if get_pty: ++ cmd = "/bin/bash -c %s" % quote(cmd) + res = pexpect.spawn(cmd, encoding='utf-8') + if need_root: + if self.config['need_sudo']: +-- +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/SPECS/sos-collector.spec b/SPECS/sos-collector.spec new file mode 100644 index 0000000..551a2fd --- /dev/null +++ b/SPECS/sos-collector.spec @@ -0,0 +1,123 @@ +Summary: Capture sosreports from multiple nodes simultaneously +Name: sos-collector +Version: 1.7 +Release: 4%{?dist} +Source0: http://people.redhat.com/jhunsake/sos-collector/%{name}-%{version}.tar.gz +License: GPLv2 +BuildArch: noarch +Url: https://github.com/sosreport/sos-collector +Requires: sos >= 3.0 +Obsoletes: clustersos < 1.2.2-2 +Provides: clustersos = %{version}-%{release} + +Patch0: sos-collector-none-cluster-fix.patch +Patch1: sos-collector-nested-container-fix.patch +Patch2: sos-collector-rhcos-image.patch +Patch3: sos-collector-pexpect.patch + +%if 0%{?rhel} == 7 +BuildRequires: python-devel +Requires: python-futures +Requires: python-six +Requires: python-pexpect +%else +BuildRequires: python3-devel +BuildRequires: python3-six +BuildRequires: python3-pexpect +Requires: python3-six +Requires: python3-pexpect +%endif + + +%description +sos-collector is a utility designed to capture sosreports from multiple nodes +at once and collect them into a single archive. If the nodes are part of +a cluster, profiles can be used to configure how the sosreport command +is run on the nodes. + +%prep +%setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%build +%if 0%{?rhel} == 7 +%py2_build +%else +%py3_build +%endif + +%install +mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1 +install -p -m644 man/en/sos-collector.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/ +%if 0%{?rhel} == 7 +%py2_install +%else +%py3_install +%endif + + + +%check +%if 0%{?rhel} == 7 +%{__python2} setup.py test +%else +%{__python3} setup.py test +%endif + +%files +%{_bindir}/sos-collector +%if 0%{?rhel} == 7 +%{python2_sitelib}/* +%else +%{python3_sitelib}/* +%endif +%{_mandir}/man1/* + +%license LICENSE + +%changelog +* Fri May 24 2019 Jake Hunsaker - 1.7-4 +- Fix local execution with pexpect + +* Thu May 02 2019 Jake Hunsaker - 1.7-3 +- Backport RHHI-V cluster profile + +* 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 + +* 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