Support for serial logs from marilith boxes
cover Support for serial logs from marilith boxes
The marilith boxes use a conserver (http://www.conserver.com/) setup for serial access. Our installation exports the logs via http allowing us to grab them with wget.
Sending debug keys with is handled separately via xenuse. xenuse ultimately speaks to the conserver too but it abstracts away the IP and port to use so this is preferred.
With these changes the correct Serial hostprop for a marilith box is:
xenuse;http http://conserver.uk.xensource.com/consoles/
PATCH 1/6 Standalone: Collect logs modified in the last hour
On failure, when the console may have been silent for a considerable time, 1s is not long enough ago.
--- Osstest/JobDB/Standalone.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Osstest/JobDB/Standalone.pm +2 -1
@@ -101,7 +101,8 @@ sub jobdb_check_other_job { } #method sub jobdb_flight_started_for_log_capture ($$) { #method my ($mo, $flight) = @_; - return time - 1; # just the most recent serial log then + return time - 60*60; # just the most recent serial log then, + # modified in the last hour } sub jobdb_enable_log_capture ($) { #method
Signature · 1 line
1.7.10.4
PATCH 2/6 TestSupport: allow multiple host serial methods
In reply to Ian Campbell--- Osstest/TestSupport.pm | 25 ++++++++++++++++++++++--- ts-logs-capture | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-)
Osstest/TestSupport.pm +22 -3
@@ -63,6 +63,7 @@ BEGIN { selecthost get_hostflags get_host_property power_state power_cycle power_cycle_time + serial_fetch_logs propname_massage get_stashed open_unique_stashfile
@@ -620,6 +621,26 @@ sub guest_check_ip ($) { $gho->{DhcpWatch}->check_ip($gho); } +#-------------- serial ------------- + +sub serial_host_setup ($) { + my ($ho) = @_; + my $methobjs = [ ]; + my $serialmeth = get_host_property($ho,'serial','noop'); + foreach my $meth (split /\;\s*/, $serialmeth) { + push @$methobjs, get_host_method_object($ho,'Serial',$meth); + } + $ho->{SerialMethobjs} = $methobjs; +} + +sub serial_fetch_logs ($) { + my ($ho) = @_; + logm("serial: collecting logs for $ho->{Name}"); + foreach my $mo (@{ $ho->{SerialMethobjs} }) { + $mo->fetch_logs(); + } +} + #---------- power cycling ---------- sub power_cycle_host_setup ($) {
@@ -721,9 +742,7 @@ sub selecthost ($) { dhcp_watch_setup($ho,$ho); power_cycle_host_setup($ho); - - my $serialmeth = get_host_property($ho,'serial','noop'); - $ho->{SerialMethobj} = get_host_method_object($ho,'Serial',$serialmeth); + serial_host_setup($ho); $ho->{IpStatic} = get_host_property($ho,'ip-addr'); if (!defined $ho->{IpStatic}) {
ts-logs-capture +1 -1
@@ -211,6 +211,6 @@ sub fetch_logs_guest ($) { } } -$ho->{SerialMethobj}->fetch_logs(); +serial_fetch_logs($ho); fetch_logs_host_guests(); logm("logs captured to $stash");
Signature · 1 line
1.7.10.4
PATCH 3/6 Serial: Refactor debug key sending into separate request_debug function
In reply to Ian CampbellThis puts the list of keys to send into common code.
--- Osstest/Serial/noop.pm | 4 ++++ Osstest/Serial/sympathy.pm | 42 +++++++++++++++++++++++++----------------- Osstest/TestSupport.pm | 12 ++++++++++++ 3 files changed, 41 insertions(+), 17 deletions(-)
Osstest/Serial/noop.pm +4 -0
@@ -39,6 +39,10 @@ sub new { return bless { }, $class; } +sub request_debug { + return 0; +} + sub fetch_logs { my ($mo) = @_; logm("serial access method \`noop',".
Osstest/Serial/sympathy.pm +25 -17
64 lines not on this page · raw message
Osstest/TestSupport.pm +12 -0
@@ -635,7 +635,19 @@ sub serial_host_setup ($) { sub serial_fetch_logs ($) { my ($ho) = @_; + + logm("serial: requesting debug information from $ho->{Name}"); + + foreach my $mo (@{ $ho->{SerialMethobjs} }) { + $mo->request_debug("\x18\x18\x18", + "0HMQacdegimnrstuvz", + "q") or next; + # use the first method which supports ->request_debug. + last; + } + logm("serial: collecting logs for $ho->{Name}"); + foreach my $mo (@{ $ho->{SerialMethobjs} }) { $mo->fetch_logs(); }
Signature · 1 line
1.7.10.4
PATCH 4/6 Serial: collect serial logs from an http server
In reply to Ian CampbellThis relies on wget and httpd colluding to set the mtimes on the downloaded files, which works with at least the one server I care about (the apache on the conserver handling the marilith boxes)
--- Osstest/Serial/http.pm | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Osstest/Serial/http.pm
Osstest/Serial/http.pm new file +114 -0
@@ -0,0 +1,114 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2013 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Fetch logs from a web directory export. + +package Osstest::Serial::http; + +use strict; +use warnings; + +use Osstest; +use Osstest::TestSupport; + +use File::Temp; +use File::Copy; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(); + %EXPORT_TAGS = ( ); + + @EXPORT_OK = qw(); +} + +sub new { + my ($class, $ho, $methname, @args) = @_; + my $mo = { Host => $ho, Name => $ho->{Name} }; + die if @args<1; + push @args, "$ho->{Name}.txt*" if @args < 2; + + logm("serial method $methname $mo->{Host}{Name}: @args"); + ($mo->{Server}, $mo->{Pattern}) = @args; + return bless $mo, $class; +} + +sub request_debug { + return 0; +} + +sub fetch_logs { + my ($mo) = @_; + + my $started= $mjobdb->jobdb_flight_started_for_log_capture($flight); + + my $ho = $mo->{Host}; + my $logpat = $mo->{Pattern}; + my $targhost= $mo->{Server}; + + logm("serial http from $mo->{Name} fetching $mo->{Pattern} from $mo->{Server}"); + + my $dir = File::Temp->newdir(); + my $tdir = $dir->dirname; + + my $lrf = "$tdir/log-retrieval.log"; + + system_checked(qw(wget -nH --cut-dirs=1 -r -l1 --no-parent), + '-o', "$lrf", + '-A', $mo->{Pattern}, + '-P', $tdir, + $mo->{Server}); + + my $sr = "serial-retrieval.log"; + my $lr = open_unique_stashfile(\$sr); + File::Copy::copy($lrf, $lr); + + my %done; + foreach my $logfile (glob "$tdir/$mo->{Pattern}") { + my $lh= new IO::File $logfile, 'r'; + if (!defined $lh) { + $!==&ENOENT or warn "$logfile $!"; + next; + } + stat $lh or die "$logfile $!"; + my $inum= (stat _)[1]; + my $lfage= (stat _)[9]; + my $df= $logfile; + $df =~ s,.*/,,; + if ($lfage < $started) { + next if $done{$inum}; + logm("$df modified $lfage, skipping") + unless $done{$inum}; + $done{$inum}= 1; + next; + } + next if defined $done{$inum} and $done{$inum} >= 2; + $done{$inum}= 2; + + $df = "serial-$df"; + logm("stashing $df"); + + my $dh= open_unique_stashfile(\$df); + File::Copy::copy($logfile, $dh); + } + return; + +} + +1;
Signature · 1 line
1.7.10.4
PATCH 5/6 Serial: new module to send debug keys via xenuse
In reply to Ian CampbellNo log retreival here, that is handled via a separate conserver.
--- Osstest/Serial/xenuse.pm | 100 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Osstest/Serial/xenuse.pm
Osstest/Serial/xenuse.pm new file +100 -0
@@ -0,0 +1,100 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2009-2013 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Send debug keys via xenuse. + +package Osstest::Serial::xenuse; + +use strict; +use warnings; + +use Osstest; +use Osstest::TestSupport; + +use File::Temp; +use File::Copy; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(); + %EXPORT_TAGS = ( ); + + @EXPORT_OK = qw(); +} + +sub new { + my ($class, $ho, $methname, @args) = @_; + my $mo = { Host => $ho, Name => $ho->{Name} }; + + logm("serial method $methname $mo->{Host}{Name}: @args"); + return bless $mo, $class; +} + +sub request_debug { + my ($mo,$conswitch,$xenkeys,$guestkeys) = @_; + my $xenuse= $c{XenUsePath} || "xenuse"; + + my $ho= $mo->{Host}; + + my $writer= sub { + my ($what,$str,$pause) = @_; + logm("xenuse sending $what"); + if (!eval { + print XENUSEWRITE $str or die $!; + sleep($pause); + 1; + }) { + warn "failed to send $what: $@\n"; + return 0; + } + return 1; + }; + + my $debugkeys= sub { + my ($what, $keys) = @_; + foreach my $k (split //, $keys) { + $writer->("$what debug info request, debug key $k", $k, 2); + } + }; + + local ($SIG{'PIPE'}) = 'IGNORE'; + open XENUSEWRITE, "|$xenuse -t $ho->{Name}" or die $!; + autoflush XENUSEWRITE 1; + + $writer->('force attach', "\x05cf", 1); # ^E c f == force attach + + $writer->('request for input to Xen', $conswitch, 1); + $debugkeys->('Xen', $xenkeys); + sleep(10); + $debugkeys->('guest', $guestkeys); + sleep(10); + $writer->("RET to dom0","$conswitch\r", 5); + + $writer->('dettach', "\x05c.", 1); # ^E c . == disconnect + + close XENUSEWRITE or die "$? $!"; + + return 1; +} + +sub fetch_logs { + return; +} + +1;
Signature · 1 line
1.7.10.4
PATCH 6/6 Serial/http: use mkdtemp instead of File::Temp->newdir
In reply to Ian CampbellThe latter is not available in Squeeze's File::Temp.
--- Osstest/Serial/http.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Osstest/Serial/http.pm +6 -5
@@ -24,7 +24,8 @@ use warnings; use Osstest; use Osstest::TestSupport; -use File::Temp; +use File::Path qw / rmtree /; +use File::Temp qw / mkdtemp /; use File::Copy; BEGIN {
@@ -64,8 +65,7 @@ sub fetch_logs { logm("serial http from $mo->{Name} fetching $mo->{Pattern} from $mo->{Server}"); - my $dir = File::Temp->newdir(); - my $tdir = $dir->dirname; + my $tdir = mkdtemp("osstest.log.XXXXX") or die $!; my $lrf = "$tdir/log-retrieval.log";
@@ -93,7 +93,7 @@ sub fetch_logs { $df =~ s,.*/,,; if ($lfage < $started) { next if $done{$inum}; - logm("$df modified $lfage, skipping") + logm("$df modified $lfage ($started), skipping") unless $done{$inum}; $done{$inum}= 1; next;
@@ -107,8 +107,9 @@ sub fetch_logs { my $dh= open_unique_stashfile(\$df); File::Copy::copy($logfile, $dh); } - return; + rmtree($tdir); + return; } 1;
Signature · 1 line
1.7.10.4
Ian Campbell writes ("[PATCH OSSTEST 0/6] Support for serial logs from marilith boxes"):
Quoted 10 lines
The marilith boxes use a conserver (http://www.conserver.com/) setup for serial access. Our installation exports the logs via http allowing us to grab them with wget.
Sending debug keys with is handled separately via xenuse. xenuse ultimately speaks to the conserver too but it abstracts away the IP and port to use so this is preferred.
With these changes the correct Serial hostprop for a marilith box is:
xenuse;http http://conserver.uk.xensource.com/consoles/
These all look plausible to me (as do your previous to); please go ahead and push them.
Ian.
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST 0/6] Support for serial logs from marilith boxes"):
Quoted 8 lines
The marilith boxes use a conserver (http://www.conserver.com/) setup for serial access. Our installation exports the logs via http allowing us to grab them with wget.
Sending debug keys with is handled separately via xenuse. xenuse ultimately speaks to the conserver too but it abstracts away the IP and port to use so this is preferred.
Quoted 5 lines
Quoted 2 lines
With these changes the correct Serial hostprop for a marilith box is:
xenuse;http http://conserver.uk.xensource.com/consoles/These all look plausible to me (as do your previous to); please go ahead and push them.
I assumed s/to/two/ and pushed all eight:
fbcda5f Serial/http: use mkdtemp instead of File::Temp->newdir
5caaf09 Serial: new module to send debug keys via xenuse
660efb2 Serial: collect serial logs from an http server
514d05e Serial: Refactor debug key sending into separate request_debug function acecbdc TestSupport: allow multiple host serial methods
cc60e34 Standalone: Collect logs modified in the last hour
5ce9690 Debian: set FANCYTTY=0 so serial logs aren't full of escape chars on Wheezy a2164c3 TestSupport: fix warning about cacheing_git when !no-reinstall
Ian.
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("[PATCH OSSTEST 0/6] Support for serial logs from marilith boxes"):
Quoted 8 lines
The marilith boxes use a conserver (http://www.conserver.com/) setup for serial access. Our installation exports the logs via http allowing us to grab them with wget.
Sending debug keys with is handled separately via xenuse. xenuse ultimately speaks to the conserver too but it abstracts away the IP and port to use so this is preferred.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
With these changes the correct Serial hostprop for a marilith box is:
xenuse;http http://conserver.uk.xensource.com/consoles/These all look plausible to me (as do your previous to); please go ahead and push them.
I assumed s/to/two/ and pushed all eight:
I also ran:
./mg-hosts setprops marilith-n5 -- serial 'xenuse;http http://conserver.uk.xensource.com/consoles/'
Ian.