Skip to content

Commit 06fa3a7

Browse files
committed
packages: Make our sosreport package compatible with new sos version
Since sos layout changed in 4.0 and CentOS 7 does not have this sos version available by default, so we need some logic in the packages in order to be compatible with sos > 4.0 and sos < 4.0. We enforce sos < 4.0 for CentOS/RHEL 7 and sos >= 4.0 for RHEL8 Fixes: #3387
1 parent f29cfa1 commit 06fa3a7

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
and enable Grafana folder generation from dashboard file structure (PR
9494
[#3620](https://github.com/scality/metalk8s/pull/3620))
9595

96+
- [#3387](https://github.com/scality/metalk8s/issues/3387) - Make
97+
metalk8s-sosreport package compatible with sos version 4.0+
98+
(PR[#3664](https://github.com/scality/metalk8s/pull/3664))
99+
96100
## Bug fixes
97101

98102
- [#3601](https://github.com/scality/metalk8s/issues/3601) - Marks

buildchain/buildchain/versions.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
K8S_VERSION: str = "1.22.5"
2323
SALT_VERSION: str = "3002.7"
2424
CONTAINERD_VERSION: str = "1.5.8"
25-
SOS_VERSION: str = "< 4.0"
2625

2726
CALICO_RELEASE: str = "1"
2827
CONTAINERD_RELEASE: str = "1"
@@ -362,8 +361,6 @@ def rpm_full_name(self) -> str:
362361
PackageVersion(name="runc"),
363362
PackageVersion(name="salt-minion", version=SALT_VERSION),
364363
PackageVersion(name="socat"),
365-
# TODO download built package dependencies
366-
PackageVersion(name="sos", version=SOS_VERSION),
367364
PackageVersion(name="util-linux"),
368365
PackageVersion(name="yum-utils"),
369366
PackageVersion(name="xfsprogs"),
@@ -381,6 +378,7 @@ def rpm_full_name(self) -> str:
381378
release="{0}.el7".format(CONTAINERD_RELEASE),
382379
),
383380
PackageVersion(name="container-selinux"), # TODO #1710
381+
PackageVersion(name="sos", version="< 4.0"),
384382
PackageVersion(
385383
name="metalk8s-sosreport",
386384
version=SHORT_VERSION,
@@ -401,6 +399,7 @@ def rpm_full_name(self) -> str:
401399
),
402400
PackageVersion(name="container-selinux"),
403401
PackageVersion(name="iptables-ebtables", override="ebtables"),
402+
PackageVersion(name="sos", version=">= 4.0"),
404403
PackageVersion(
405404
name="metalk8s-sosreport",
406405
version=SHORT_VERSION,

packages/common/metalk8s-sosreport/containerd.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#! /bin/env python3
22

3-
from sos.plugins import Plugin, RedHatPlugin
3+
# sos plugin layout changed in sos 4.0
4+
try:
5+
from sos.report.plugins import Plugin, RedHatPlugin
6+
except ImportError:
7+
from sos.plugins import Plugin, RedHatPlugin
48

59

610
class containerd(Plugin, RedHatPlugin):

packages/common/metalk8s-sosreport/metalk8s.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from os import path
44

55
import requests
6-
from sos.plugins import Plugin, RedHatPlugin
6+
7+
# sos plugin layout changed in sos 4.0
8+
try:
9+
from sos.report.plugins import Plugin, RedHatPlugin
10+
except ImportError:
11+
from sos.plugins import Plugin, RedHatPlugin
712

813

914
class metalk8s(Plugin, RedHatPlugin):

packages/redhat/common/metalk8s-sosreport.spec

+19-15
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ Summary: Metalk8s SOS report custom plugins
55

66
BuildRequires: /usr/bin/pathfix.py
77

8-
# Does not work with 4.0.0 and later
9-
Requires: sos >= 3.1, sos < 4.0
8+
# sos layout changed in version 4.0, in order to make things simpler
9+
# let's consider we have sos >= 4.0 for RHEL 8+ and sos < 4.0 for RHEL 7
1010
%if 0%{rhel} >= 8
11+
Requires: sos >= 4.0
1112
Requires: python3 >= 3.6
1213
%else
14+
Requires: sos >= 3.1, sos < 4.0
1315
Requires: python >= 2.6, python < 2.8
1416
# NameError on FileNotFoundError in sos 3.5 python2.7
1517
Conflicts: sos = 3.5
@@ -27,14 +29,16 @@ Source1: ../../common/metalk8s-sosreport/containerd.py
2729

2830
%if 0%{rhel} >= 8
2931
%define python_lib %{python3_sitelib}
32+
%define report_plugins %{python_lib}/sos/report/plugins
3033
%else
3134
%define python_lib %{python_sitelib}
35+
%define report_plugins %{python_lib}/sos/plugins
3236
%endif
3337

3438
%install
35-
install -m 755 -d %{buildroot}/%{python_lib}/sos/plugins
36-
install -p -m 755 %{_topdir}/SOURCES/metalk8s.py %{buildroot}/%{python_lib}/sos/plugins/metalk8s.py
37-
install -p -m 755 %{_topdir}/SOURCES/containerd.py %{buildroot}/%{python_lib}/sos/plugins/containerd.py
39+
install -m 755 -d %{buildroot}/%{report_plugins}
40+
install -p -m 755 %{_topdir}/SOURCES/metalk8s.py %{buildroot}/%{report_plugins}/metalk8s.py
41+
install -p -m 755 %{_topdir}/SOURCES/containerd.py %{buildroot}/%{report_plugins}/containerd.py
3842
%if 0%{rhel} >= 8
3943
pathfix.py -pni "%{__python3} %{py3_shbang_opts}" %{buildroot}%{python_lib}
4044
%else
@@ -43,18 +47,18 @@ pathfix.py -pni "%{__python} %{py_shbang_opts}" %{buildroot}%{python_lib}
4347

4448
%files
4549
%defattr(-,root,root)
46-
%{python_lib}/sos/plugins/containerd.py
47-
%{python_lib}/sos/plugins/metalk8s.py
50+
%{report_plugins}/containerd.py
51+
%{report_plugins}/metalk8s.py
4852
%if 0%{rhel} >= 8
49-
%{python_lib}/sos/plugins/__pycache__/containerd.cpython-%{python3_version_nodots}.pyc
50-
%{python_lib}/sos/plugins/__pycache__/containerd.cpython-%{python3_version_nodots}.opt-?.pyc
51-
%{python_lib}/sos/plugins/__pycache__/metalk8s.cpython-%{python3_version_nodots}.pyc
52-
%{python_lib}/sos/plugins/__pycache__/metalk8s.cpython-%{python3_version_nodots}.opt-?.pyc
53+
%{report_plugins}/__pycache__/containerd.cpython-%{python3_version_nodots}.pyc
54+
%{report_plugins}/__pycache__/containerd.cpython-%{python3_version_nodots}.opt-?.pyc
55+
%{report_plugins}/__pycache__/metalk8s.cpython-%{python3_version_nodots}.pyc
56+
%{report_plugins}/__pycache__/metalk8s.cpython-%{python3_version_nodots}.opt-?.pyc
5357
%else
54-
%{python_lib}/sos/plugins/metalk8s.pyc
55-
%{python_lib}/sos/plugins/containerd.pyc
56-
%{python_lib}/sos/plugins/metalk8s.pyo
57-
%{python_lib}/sos/plugins/containerd.pyo
58+
%{report_plugins}/metalk8s.pyc
59+
%{report_plugins}/containerd.pyc
60+
%{report_plugins}/metalk8s.pyo
61+
%{report_plugins}/containerd.pyo
5862
%endif
5963

6064
%changelog

0 commit comments

Comments
 (0)