import sos-collector-1.7-4.el8

This commit is contained in:
CentOS Sources 2019-08-01 20:42:38 -04:00 committed by Stepan Oksanichenko
commit 992cea58ee
7 changed files with 273 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/sos-collector-1.7.tar.gz

1
.sos-collector.metadata Normal file
View File

@ -0,0 +1 @@
5a4f3d843e90ac35af70c2da2e1b18a62df036c3 SOURCES/sos-collector-1.7.tar.gz

View File

@ -0,0 +1,59 @@
From 0bc831a07be6ae837cb9029943c57255c47b647f Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
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 <jhunsake@redhat.com>
---
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

View File

@ -0,0 +1,30 @@
From a614ed8e5621f931d8ee76f1f59747a46144cb2d Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
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 <jhunsake@redhat.com>
---
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

View File

@ -0,0 +1,30 @@
From 76ca28dc5ce222d24086b387a448ceeb53055e4b Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
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 <jhunsake@redhat.com>
---
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

View File

@ -0,0 +1,29 @@
From 6dafb42064b06a80720c6017e2576aea9a7211de Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
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 <jhunsake@redhat.com>
---
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

123
SPECS/sos-collector.spec Normal file
View File

@ -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 <jhunsake@redhat.com> - 1.7-4
- Fix local execution with pexpect
* Thu May 02 2019 Jake Hunsaker <jhunsake@redhat.com> - 1.7-3
- Backport RHHI-V cluster profile
* Thu Apr 11 2019 Jake Hunsaker <jhunsake@redhat.com> - 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 <jhunsake@redhat.com> - 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 <jhunsake@redhat.com> - 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 <jhunsake@redhat.com> - 1.5-1
- New upstream release
- Resolves CVE-2018-14650
* Fri Jun 22 2018 Jake Hunsaker <jhunsake@redhat.com> 1.4-1
- New upstream release
* Thu May 24 2018 Jake Hunsaker <jhunsake@redhat.com> 1.3-3
- Fix sos-collector archive organization
- Fix cluster option validation
* Mon May 07 2018 Jake Hunsaker <jhunsake@redhat.com> 1.3-2
- Fix collection of sosreport tarballs
* Fri Apr 27 2018 Jake Hunsaker <jhunsake@redhat.com> 1.3-1
- Reset versioning to continue from clustersos
* Thu Apr 26 2018 Jake Hunsaker <jhunsake@redhat.com> 1.0-1
- Renamed project to sos-collector
- Moved github repo to sosreport org