Merge lp://qastaging/~pfalcon/linaro-android-build-tools/slave-logs into lp://qastaging/linaro-android-build-tools

Proposed by Paul Sokolovsky
Status: Merged
Merged at revision: 433
Proposed branch: lp://qastaging/~pfalcon/linaro-android-build-tools/slave-logs
Merge into: lp://qastaging/linaro-android-build-tools
Diff against target: 23 lines (+16/-0)
1 file modified
utils/slave-logs/archive-slave-logs (+16/-0)
To merge this branch: bzr merge lp://qastaging/~pfalcon/linaro-android-build-tools/slave-logs
Reviewer Review Type Date Requested Status
Deepti B. Kalakeri (community) Needs Fixing
James Tunnicliffe (community) Approve
Linaro Infrastructure Pending
Review via email: mp+100795@code.qastaging.launchpad.net

Description of the change

Jenkins EC2 plugins stupidly puts slave logs straight into $JENKINS_HOME, where they pile up until being remove to not cloud vision. And that's bad, because slave logs is important asset allowing to analyze system performance and behavior.

So instead, move them to $JENKINS_HOME/slave-logs/, and also make them sort naturally by date. Granted, one could use ls with obscure switches to sort by m_time, but what if I want to grep last month's logs? Would be too cumbersome. So, it's all about accessibility.

This is to be deployed on both a-b and ci.*.

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks fine to me.

review: Approve
Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :
Download full text (3.4 KiB)

On Wed, Apr 4, 2012 at 7:25 PM, Paul Sokolovsky
<email address hidden>wrote:

> Paul Sokolovsky has proposed merging
> lp:~pfalcon/linaro-android-build-tools/slave-logs into
> lp:linaro-android-build-tools.
>
> Requested reviews:
> Deepti B. Kalakeri (deeptik)
> James Tunnicliffe (dooferlad)
> Linaro Infrastructure (linaro-infrastructure)
>
> For more details, see:
>
> https://code.launchpad.net/~pfalcon/linaro-android-build-tools/slave-logs/+merge/100795<https://code.launchpad.net/%7Epfalcon/linaro-android-build-tools/slave-logs/+merge/100795>
>
> Jenkins EC2 plugins stupidly puts slave logs straight into $JENKINS_HOME,
> where they pile up until being remove to not cloud vision. And that's bad,
> because slave logs is important asset allowing to analyze system
> performance and behavior.
>
> So instead, move them to $JENKINS_HOME/slave-logs/, and also make them
> sort naturally by date. Granted, one could use ls with obscure switches to
> sort by m_time, but what if I want to grep last month's logs? Would be too
> cumbersome. So, it's all about accessibility.
>
> This is to be deployed on both a-b and ci.*.
>
> --
>
> https://code.launchpad.net/~pfalcon/linaro-android-build-tools/slave-logs/+merge/100795<https://code.launchpad.net/%7Epfalcon/linaro-android-build-tools/slave-logs/+merge/100795>
> You are requested to review the proposed merge of
> lp:~pfalcon/linaro-android-build-tools/slave-logs into
> lp:linaro-android-build-tools.
>
> === added directory 'utils/slave-logs'
> === added file 'utils/slave-logs/archive-slave-logs'
> --- utils/slave-logs/archive-slave-logs 1970-01-01 00:00:00 +0000
> +++ utils/slave-logs/archive-slave-logs 2012-04-04 13:54:08 +0000
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +#
> +# This script moves EC2 build slave logs, which short-sightedly
> +# put straight into JENKINS_HOME by EC2 plugin, into slave-logs/ subdir.
> +# While moving, it also prefixes each log with a date, to facilitate
> +# log analysis, querying and grepping.
> +#
> +# It is intended to be run as a cronjob.
> +#
> +
> +JENKINS_HOME=/var/lib/jenkins
> +
> +cd $JENKINS_HOME
> +mkdir -p slave-logs
> +
> +ls -l slave-*.log | awk ' {print $8 " " "slave-logs/" $6 "-" $8}' | xargs
> -n2 mv
>

In the above command for the slave log name we are just trying to use the
month name and time stamp, which would not be of much help.
If 2 different slaves are started at the same timestamp then we will end up
overwriting the old slave with the new one.
If you want to rename the file it would be good to retain the slave name as
well along with date and timestamp.

Between, the command needs to be tweaked little bit, the commands fails to
move as below:

ls -l slave-*.log | awk ' {print $8 " " "slave-logs/" $6 "-" $8}' | xargs
-n2 mv
mv: cannot stat `04:25': No such file or directory

that is because $8 contains the timestamp and not the slave log file name
to be moved.
Also, instead of renaming the file we could just move it as the move
command retains the original mtime and the date of the file.
so a simple command like below would work

mv `ls slave-i-*log` slave-logs/

OR
If you want it to rename the file we could use the following command or
something si...

Read more...

Revision history for this message
Deepti B. Kalakeri (deeptik) :
review: Needs Fixing
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Deepti: where did you try to run that script exactly? It works find on contemporary Ubuntu and on android-build and ci.* specifically.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

And it of course designed to preserve anything which needs to be preserved in the original filename (i.e. all characters) - how else could it be?

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

On Thu, Apr 5, 2012 at 3:04 PM, Paul Sokolovsky
<email address hidden>wrote:

> Deepti: where did you try to run that script exactly? It works find on
> contemporary Ubuntu and on android-build and ci.* specifically.
>

I just ran the command from the command line on ci* slave logs.

>
> --
>
> https://code.launchpad.net/~pfalcon/linaro-android-build-tools/slave-logs/+merge/100795<https://code.launchpad.net/%7Epfalcon/linaro-android-build-tools/slave-logs/+merge/100795>
> You are reviewing the proposed merge of
> lp:~pfalcon/linaro-android-build-tools/slave-logs into
> lp:linaro-android-build-tools.
>

--
Thanks and Regards,
Deepti

434. By Paul Sokolovsky

Need to take care of duplicate instance IDs too.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

So did I, in debug mode (echo added) for starters:

$ ./archive-slave-logs
mv slave-i-1b19dd7c.log slave-logs/2012-04-05-slave-i-1b19dd7c.log
mv slave-i-6b0dc80c.log slave-logs/2012-04-05-slave-i-6b0dc80c.log
mv slave-i-6b4c880c.log slave-logs/2012-04-05-slave-i-6b4c880c.log
mv slave-i-7fe12418.log slave-logs/2012-04-05-slave-i-7fe12418.log
mv slave-i-9d748afa.log slave-logs/2012-04-05-slave-i-9d748afa.log
mv slave-i-9f4c88f8.log slave-logs/2012-04-05-slave-i-9f4c88f8.log
mv slave-i-ad33f7ca.log slave-logs/2012-04-05-slave-i-ad33f7ca.log
mv slave-i-b920e4de.log slave-logs/2012-04-05-slave-i-b920e4de.log
mv slave-i-bb20e4dc.log slave-logs/2012-04-05-slave-i-bb20e4dc.log
mv slave-i-c1dd18a6.log slave-logs/2012-04-05-slave-i-c1dd18a6.log
mv slave-i-d71ee4b0.log slave-logs/2012-04-05-slave-i-d71ee4b0.log

As we see, the problem here is that it doesn't include slave-*.log.* (duplicate EC2 instance IDs case), fixed. Otherwise, works fine.

435. By Paul Sokolovsky

Now again, catch non-dup logs.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

As an extra caution, I checked that moving a log for slave being run is ok (i.e. EC2 plugin keeps file open, and writes to it by file descriptor).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches