RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1771798 - sosreport collects files which are under /var/log/sa/ without 25MB limitation despite no all_sar option
Summary: sosreport collects files which are under /var/log/sa/ without 25MB limitation...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sos
Version: 8.0
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: 8.0
Assignee: Pavel Moravec
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks: 1825061
TreeView+ depends on / blocked
 
Reported: 2019-11-13 02:05 UTC by Ryo Hayakawa
Modified: 2023-12-15 16:56 UTC (History)
6 users (show)

Fixed In Version: sos-3.9.1-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 01:57:52 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sosreport sos issues 1863 0 None closed [sar] limitation by --log-size does not work 2020-11-03 14:13:38 UTC
Red Hat Product Errata RHEA-2020:4534 0 None None None 2020-11-04 01:58:11 UTC

Description Ryo Hayakawa 2019-11-13 02:05:41 UTC
Description of problem:

Although there are files with total size of more than 25MB which are under /var/log/sa/ directory, sosreport command collects all the files.
That did not occur on sos-3.6-10.el8.

Version-Release number of selected component (if applicable):
sos-3.7-6.el8_1

Steps to Reproduce:

1. check the existence of files with total size of over 25MB under /var/log/sa/.
    [root@localhost ~]# ls -lh /var/log/sa
    total 33M
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa01
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa02
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa03
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa04
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa05
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa06
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa07
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa08
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa09
    -rw-r--r--. 1 root root 2.6M Nov 12 20:01 sa10
    -rw-r--r--. 1 root root 2.6M Nov 12 20:18 sa11
    -rw-r--r--. 1 root root 2.6M Nov 12 20:31 sa13
    -rw-r--r--. 1 root root 2.6M Nov 12 20:31 sa14
    [root@localhost ~]# 


2. run the sosreport command with --only-plugins=sar
    [root@localhost ~]# sosreport --only-plugins=sar
    
    sosreport (version 3.7)
    
    This command will collect diagnostic and configuration information from
       :(snip)
    Your sosreport has been generated and saved in:
      /var/tmp/sosreport-localhost-2019-11-12-onrresf.tar.xz
       :(snip)

3. check files in the sosreport- archive file.
    [root@localhost ~]# tar tvJf /var/tmp/sosreport-localhost-2019-11-12-onrresf.tar.xz
       :(snip)
    drwxr-xr-x root/root         0 2019-11-12 20:31 sosreport-localhost-2019-11-12-onrresf/var/log/sa/
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa01
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa02
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa03
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa04
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa05
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa06
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa07
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa08
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa09
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa10
    -rw-r--r-- root/root   2636200 2019-11-12 20:18 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa11
    -rw-r--r-- root/root   2636200 2019-11-12 20:31 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa13
    -rw-r--r-- root/root   2636200 2019-11-12 20:31 sosreport-localhost-2019-11-12-onrresf/var/log/sa/sa14
    -rw-r--r-- root/root        31 2019-11-12 20:33 sosreport-localhost-2019-11-12-onrresf/version.txt


Actual results:

As above, the archive file contains the files with total size of over 25MB under /var/log/sa/.


Expected results:

The sosreport command should not include files with total size of over 25MB under /var/log/sa/ like sos-3.6-10.el8.
FYI, the following is result in the case of sos-3.6-10.el8.

    [root@localhost ~]# tar tvJf /var/tmp/sosreport-localhost-2019-11-12-ytxhrol.tar.xz
    drwxr-xr-x root/root         0 2019-11-12 20:40 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/
    -rw-r--r-- root/root   2636200 2019-11-12 20:31 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa14
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa10
    -rw-r--r-- root/root      4272 2019-11-12 20:50 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa12
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa08
    -rw-r--r-- root/root   2636200 2019-11-12 20:18 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa11
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa09
    -rw-r--r-- root/root   2636200 2019-11-12 20:01 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa07
    -rw-r--r-- root/root   2636200 2019-11-12 20:31 sosreport-localhost-2019-11-12-ytxhrol/var/log/sa/sa13
    -rw-r--r-- root/root        31 2019-11-12 20:53 sosreport-localhost-2019-11-12-ytxhrol/version.txt


Additional info:

I think that the sos-bz1714243-sar-collect-older-data.patch unintentionally causes this issue.
According to the following source code, when the "all_sar" option is not specified, the sizelimit option is passed as None and the the copyspecs is passed as "/var/log/sa" directory to the add_copy_spec().

- sos/plugins/sar.py (sos-3.7-6.el8_1) :
     20     packages = ('sysstat',)
     21     sa_path = '/var/log/sa'
     22     option_list = [("all_sar", "gather all system activity records",
     23                     "", False)]
     24
     25     def setup(self):
     26         self.add_copy_spec(self.sa_path,
     27                            sizelimit=0 if self.get_option("all_sar") else None)
     28
     29         try:
     30             dir_list = os.listdir(self.sa_path)

Then, the copyspecs(="/var/log/sa") is passed to the "_file" variable in the sos/plugins/__init__.py:add_copy_spec() and os.stat() calculates the size of "/var/log/sa" as directory (the 815 line of the sos/plugins/__init__.py).

- sos/plugins/__init__.py:
    810             for _file in files:
    811                 if self._is_forbidden_path(_file):
    812                     self._log_debug("skipping forbidden path '%s'" % _file)
    813                     continue
    814                 try:
    815                     current_size += os.stat(_file)[stat.ST_SIZE]

The size is small because the _file's value is not file but directory (54 bytes in my environment). It causes unlimited collection of files of /var/log/sa/* despite no "all_sar" option.

Our customer would like to have this problem fixed.
I kindly ask for your confirmation

Regards,

Comment 1 Pavel Moravec 2019-11-13 06:56:50 UTC
A known (upstream) issue: https://github.com/sosreport/sos/issues/1750

Specifically for sar, one can code-workaround it via 

        self.add_copy_spec(self.sa_path+"/*",

is sar.py (not a clean fix, though).

Comment 2 Pavel Moravec 2020-04-13 13:40:19 UTC
Will appear in RHEL8.3 as:
- the fix in https://github.com/sosreport/sos/issues/1863 is in sos-3.9.1
- 8.3 should rebase sos to 3.9-1 or future 4.0

Comment 9 errata-xmlrpc 2020-11-04 01:57:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sos bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:4534


Note You need to log in before you can comment on or make changes to this bug.