Compress host allocation logs
cover Compress host allocation logs
These are voluminous and will compress well. We do want to keep the whole log, because it is sometimes necessary to go back into the log to see where some glitch happened.
1/3 Executive: support DebugFh xparam to alloc_resources 2/3 TestSupport: logm: allow $logm_handle to be an aref 3/3 ts-hosts-allocate-Executive: Compress debug output
I'm going to push these onto my wip branch, which contains changes which are queued up pending various other more urgent work on osstest.
PATCH 1/3 Executive: support DebugFh xparam to alloc_resources
This redirects some of the more verbose output (the json dumps) elsewhere. If DebugFh is not set, this output is suppressed.
ts-hosts-allocate-Executive provides DebugFh pointing to its DEBUG fh.
--- Osstest/Executive.pm | 11 +++++++++-- ts-hosts-allocate-Executive | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
Osstest/Executive.pm +9 -2
@@ -362,6 +362,11 @@ sub alloc_resources { logm("resource allocation: starting..."); + my $debugfh = $xparams{DebugFh}; + my $debugm = $debugfh + ? sub { print $debugfh @_, "\n" or die $!; } + : sub { }; + my $set_info= sub { return if grep { !defined } @_; my @s;
@@ -449,7 +454,8 @@ sub alloc_resources { read($qserv, $jplan, $jplanlen) == $jplanlen or die $!; my $jplanprint= $jplan; chomp $jplanprint; - logm("resource allocation: base plan $jplanprint"); + logm("resource allocation: obtained base plan."); + $debugm->("base plan = ", $jplanprint); $plan= from_json($jplan); }, sub { if (!eval {
@@ -465,7 +471,8 @@ sub alloc_resources { if ($bookinglist && $ok!=-1) { my $jbookings= to_json($bookinglist); chomp($jbookings); - logm("resource allocation: booking $jbookings"); + logm("resource allocation: booking."); + $debugm->("bookings = ", $jbookings); printf $qserv "book-resources %d\n", length $jbookings or die $!;
ts-hosts-allocate-Executive +1 -0
@@ -526,6 +526,7 @@ sub alloc_hosts () { alloc_resources(WaitStart => ($ENV{OSSTEST_RESOURCE_WAITSTART} || $fi->{started}), WaitStartAdjust => $waitstartadjust, + DebugFh => \*DEBUG, \&attempt_allocation); foreach my $hid (@hids) {
Signature · 1 line
1.7.10.4
PATCH 2/3 TestSupport: logm: allow $logm_handle to be an aref
In reply to Ian JacksonIf $logm_handle is an array reference, iterate over it. This allows calling code to duplicate the messages.
--- Osstest/TestSupport.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Osstest/TestSupport.pm +8 -5
@@ -175,11 +175,14 @@ sub ts_get_host_guest { # pass this @ARGV sub logm ($) { my ($m) = @_; my @t = gmtime; - printf $logm_handle "%04d-%02d-%02d %02d:%02d:%02d Z %s\n", - $t[5]+1900,$t[4]+1,$t[3], $t[2],$t[1],$t[0], - $m - or die $!; - $logm_handle->flush or die $!; + my $fm = sprintf "%04d-%02d-%02d %02d:%02d:%02d Z %s\n", + $t[5]+1900,$t[4]+1,$t[3], $t[2],$t[1],$t[0], + $m; + foreach my $h ((ref($logm_handle) eq 'ARRAY') + ? @$logm_handle : $logm_handle) { + print $h $fm or die $!; + $h->flush or die $!; + } } sub fail ($) {
Signature · 1 line
1.7.10.4
PATCH 3/3 ts-hosts-allocate-Executive: Compress debug output
In reply to Ian JacksonSend the voluminous host allocation debug output to a compressed logfile "hosts-allocate.debug.gz". Also send a copy of the logm output to the debug log, by manipulating $logm_handle.
Remove the bodge which unshifted -D onto the arguments, and then parsed it. Now the script takes no options.
--- ts-hosts-allocate-Executive | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
ts-hosts-allocate-Executive +13 -5
@@ -29,15 +29,12 @@ tsreadconfig(); open DEBUG, ">/dev/null" or die $!; -unshift @ARGV, '-D'; - while (@ARGV and $ARGV[0] =~ m/^-/) { $_= shift @ARGV; last if m/^--$/; while (m/^-./) { - if (s/^-D/-/) { - open DEBUG, ">&STDERR" or die $!; - DEBUG->autoflush(1); + if (0) { + # no options } else { die "$_ ?"; }
@@ -63,6 +60,17 @@ sub setup () { $taskid= findtask(); + my $logbase = "hosts-allocate.debug.gz"; + my $logfh = open_unique_stashfile \$logbase; + my $logchild = open DEBUG, "|-"; defined $logchild or die $!; + if (!$logchild) { + open STDOUT, ">&", $logfh or die $!; + exec "gzip" or die $!; + } + DEBUG->autoflush(1); + logm("host allocation debug log in $logbase"); + $logm_handle = [ $logm_handle, \*DEBUG ]; + $fi= $dbh_tests->selectrow_hashref(<<END, {}, $flight); SELECT * FROM flights WHERE flight = ?
Signature · 1 line
1.7.10.4