[sos-devel] [PATCH 1/2] [plugin] allow reverse ordering in add_copy_spec_limit

Bryn M. Reeves bmr at redhat.com
Tue Aug 19 10:15:25 UTC 2014


On Tue, Aug 19, 2014 at 11:05:36AM +0200, Sandro Bonazzola wrote:
> Added parameter to add_copy_spec_limit for allowing
> to use reverse ordering while collecting files.
> Without this time-stamped log files will be collected
> always starting from oldest so most recent logs wasn't
> in the report.

I don't really see a need for putting this under the control of the
caller. The two common methods for marking rotated log files are to
append a '.' followed by a generation number (e.g. mylog, mylog.1,
mylog.2 etc.) or to add a '-' followed by a date in ISO 8601 format
(e.g. alog, alog-20140701, alog-20140707). Both of these formats should
place the un-rotated (current) log first in normal glob ordering:

  $ ls a.log* 
  a.log  a.log-20140816  a.log-20140818
  $ ls b*
  b  b.1  b.2  b.3  b.4

The python interpreter consistently inverts the sort order (on both py2
& py3 runtimes):

Python 2.7.5 (default, Jun 25 2014, 10:19:55) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> print glob.glob("a.log*")
['a.log-20140816', 'a.log-20140818', 'a.log']
>>> 

Python 3.3.2 (default, Jun 30 2014, 17:20:03) 
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> print(glob.glob("a.log*"))
['a.log-20140816', 'a.log-20140818', 'a.log']
>>> 

Given that I don't really think the reverse_order kwarg is desirable; I
don't see a valid use for /not/ setting it. Imho it's better to change
the default sort ordering for all users (and to be consistent with the
behaviour of the shell).

Regards,
Bryn.

> Change-Id: I8dfd0dd3936ae99ea19d975c092a1b275b5e3f4f
> Signed-off-by: Sandro Bonazzola <sbonazzo at redhat.com>
> ---
>  sos/plugins/__init__.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)




More information about the sos-devel mailing list