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 1061529 - addCopySpecLimit function doesn't consider file sizes in recursive subdirectories
Summary: addCopySpecLimit function doesn't consider file sizes in recursive subdirecto...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sos
Version: 6.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: David Kutálek
URL:
Whiteboard:
Depends On:
Blocks: 1056252 1344147
TreeView+ depends on / blocked
 
Reported: 2014-02-05 02:39 UTC by Dustin Black
Modified: 2018-12-09 17:29 UTC (History)
6 users (show)

Fixed In Version: sos-2.2-55.el6
Doc Type: Bug Fix
Doc Text:
No documentation needed.
Clone Of:
: 1344147 (view as bug list)
Environment:
Last Closed: 2014-10-14 07:23:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Test script to reproduce and highlight the problem (1.55 KB, text/x-python)
2014-02-05 02:39 UTC, Dustin Black
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1528 0 normal SHIPPED_LIVE sos bug fix and enhancement update 2014-10-14 01:22:00 UTC

Description Dustin Black 2014-02-05 02:39:49 UTC
Created attachment 859441 [details]
Test script to reproduce and highlight the problem

Description of problem:
When addCopySpecLimit() is used to collect content of a directory with a specified limit, only the sizes of files in the directory root for the applied limit are considered in the size calculation. Sub-directories are collected in-full without consideration of the limit.

Because the directory contents are processed alphabetically, the result could be that directory a is collected in-full regardless of it's content size, files b-e are collected, file f exceeds the limit and is not collected, and directory g is not collected because the limit has already been exceeded.

Version-Release number of selected component (if applicable):
sos-2.2-38.el6_4.2

How reproducible:
Consistently

Steps to Reproduce:
See attached sosSpecTest.py

Actual results:
addCopySpecLimit() used on a directory will collect subdirectories without limit, and will not collect subdirectories at all if they fall alphabetically after the defined limit has been reached.

Expected results:
The limit should consider file sizes in the subdirectories against the defined limit, or perhaps offer an option to duplicate the limit for subdirectories recursively (such that a 15MB limit will apply to the root, and another 15MB to directory a, and another to directory a/b, and so forth -- Of course, some final limit should also be defined).

Additional info:
Testing and analysis from Brian Harrington:

In testing of the gluster sos report plugin patches I was writing for BZ 1002619 I found the following discrepancy.  Despite setting a limit on the size of files to be copied, it was not being honored.  Creating a sample set including:

  50MB cli.log.1
  100MB file in /var/log/glusterfs/bricks

it was seen that the bricks directory would be zipped up because the file globbing + size check are only done against the individual files while directories are only seen as 4k, not the size of their contents.

This is due to how to how the addCopySpecLimit() function in /usr/lib/python2.6/site-packages/sos/plugintools.py is implemented.

        files = glob.glob(fname)
        files.sort()
        cursize = 0
        limit_reached = False
        sizelimit *= 1024 * 1024 # in MB
        for flog in files:
            cursize += os.stat(flog)[ST_SIZE]
            if sizelimit and cursize > sizelimit:
                limit_reached = True

If the path is specified as "/*" it will calculate individual files, but skip everything after a single over size file is found.

[root@broker tmp]# ./test.py
   Size 4          /var/log/glusterfs/bricks
   Size 7          /var/log/glusterfs/cli.log
** Size 50024      /var/log/glusterfs/cli.log.1
** Size 12         /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
** Size 4          /var/log/glusterfs/geo-replication
** Size 4          /var/log/glusterfs/geo-replication-slaves
   Size 4          /var/log/glusterfs/geo-replication/
   Size 4          /var/log/glusterfs/geo-replication-slaves/
[root@broker tmp]# du -hsxc /var/log/glusterfs/
176M        /var/log/glusterfs/
176M        total
[root@broker tmp]# ls -lRh /var/log/glusterfs/
/var/log/glusterfs/:
total 49M
drwxr-xr-x. 2 root root 4.0K Feb  4 20:08 bricks
-rw-------. 1 root root 7.3K Feb  4 20:45 cli.log
-rw-r--r--. 1 root root  49M Feb  4 19:58 cli.log.1
-rw-------. 1 root root  13K Feb  4 20:45 etc-glusterfs-glusterd.vol.log
drwxr-xr-x. 2 root root 4.0K Feb  4 19:56 geo-replication
drwxr-xr-x. 3 root root 4.0K Feb  4 19:56 geo-replication-slaves

/var/log/glusterfs/bricks:
total 127M
-rw-r--r--. 1 root root 9.8M Feb  4 20:07 brick.log
-rw-r--r--. 1 root root 9.8M Feb  4 20:07 brick.log.1
-rw-r--r--. 1 root root 9.8M Feb  4 20:07 brick.log.2
-rw-r--r--. 1 root root  98M Feb  4 20:08 brick.log.3

/var/log/glusterfs/geo-replication:
total 0

/var/log/glusterfs/geo-replication-slaves:
total 4.0K
drwxr-xr-x. 2 root root 4.0K Feb  4 19:56 mbr

/var/log/glusterfs/geo-replication-slaves/mbr:
total 0

Comment 2 Bryn M. Reeves 2014-02-12 16:35:56 UTC
When this API was added back in 2010 the developer only really considered the case of adding a file or set of files (via glob). The code was never designed to take recursive directory trees into account which it should, obviously.

Until now we've largely avoided the problem since the in-tree users have mostly passed absolute paths or globs expanding to a list of files (although I just noticed the cups plugin is passing a directory and so will have the same problem described here).

Personally I've never much liked the interface - it leaves far too much ambiguity for the caller and expects the implementation to know the right thing to do. If there is a limit in place then clearly at some point we need to stop collecting more data - the difficulty for the implementation is knowing when it's "right" to do that (right now it just depends on sort ordering so it's unpredictable as noted here).

I don't have a good solution for this right now but I'll spend some more time looking at this this week. In the short term where possible the interface should not be used to collect whole directory trees.

Comment 5 Bryn M. Reeves 2014-06-20 16:23:55 UTC
The following patches have been committed to the rhel-6 branch (sos-2.2) to address this bug:

commit 6bc0a350fdccdf8f663af02e69ea0467c3ddbfc5
Author: Bryn M. Reeves <bmr>
Date:   Fri Jun 20 18:51:34 2014 +0100

    [auditd] fix log size limiting

commit fb4fa2107dab487880c8147d64cb78509cb780fa
Author: Bryn M. Reeves <bmr>
Date:   Fri Jun 20 14:30:29 2014 +0100

    [printing] fix cups log file size limiting
    
    Signed-off-by: Bryn M. Reeves <bmr>

commit 1985b0b20f4157407585ae9b85df6988c97d38c5
Author: Bryn M. Reeves <bmr>
Date:   Thu Jun 19 17:19:58 2014 +0100

    [gluster] update plugin and add log file size-limiting


With these changes all users of addCopySpecLimit in RHEL6 now pass either a single file or a glob that expands to a list of files to this method:

# grep -r addCopySpecLimit sos/plugins/
sos/plugins/nscd.py:                self.addCopySpecLimit(f[1],
sos/plugins/general.py:        self.addCopySpecLimit("/var/log/messages*", sizelimit = self.getOption("syslogsize"))
sos/plugins/general.py:        self.addCopySpecLimit("/var/log/secure*", sizelimit = self.getOption("syslogsize"))
sos/plugins/general.py:                    self.addCopySpecLimit(i, sizelimit = self.isOptionEnabled("syslogsize"))
sos/plugins/printing.py:            self.addCopySpecLimit("/var/log/cups/access_log", sizelimit=limit)
sos/plugins/printing.py:            self.addCopySpecLimit("/var/log/cups/error_log", sizelimit=limit)
sos/plugins/printing.py:            self.addCopySpecLimit("/var/log/cups/page_log", sizelimit=limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/cli.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/*.vol.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/gluster-lock.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/glustershd.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/nfs.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/quota-crawl.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/quotad.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/quotad-mount-*.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/status.log", limit)
sos/plugins/gluster.py:            self.addCopySpecLimit("/var/log/glusterfs/bricks/*.log", limit)
sos/plugins/squid.py:        self.addCopySpecLimit("/var/log/sqid/access.log",
sos/plugins/squid.py:        self.addCopySpecLimit("/var/log/sqid/cache.log",
sos/plugins/squid.py:        self.addCopySpecLimit("/var/log/sqid/squid.out",
sos/plugins/auditd.py:            self.addCopySpecLimit("/var/log/audit/audit.log", sizelimit = limit)

Comment 8 errata-xmlrpc 2014-10-14 07:23:01 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2014-1528.html


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