Commit 45be13a8 authored by Kevin Atkinson's avatar Kevin Atkinson

Fix bug which was displaying "/2 xxx's ... failed ..." when there

where no failed nodes for that pc type, it will now display "2 xxx's
... successfully ...".

Add "no warnings 'uninitialized'" inside loop since I want undefined
to mean zero.  Revert previous (incomplete) fix by checking if it
is defined first.
parent 7d62d520
...@@ -1174,7 +1174,7 @@ tballdone: ...@@ -1174,7 +1174,7 @@ tballdone:
tbinfo "OS Setup Done."; tbinfo "OS Setup Done.";
my %tally; my %tally;
my $users_fought = 1; my $users_fault = 1;
my %total_osid; my %total_osid;
my %total_type; my %total_type;
my $summary = ''; my $summary = '';
...@@ -1208,10 +1208,13 @@ foreach ((keys %nodes), (keys %vnodes), (keys %plabvnodes)) { ...@@ -1208,10 +1208,13 @@ foreach ((keys %nodes), (keys %vnodes), (keys %plabvnodes)) {
} }
foreach my $osid (sort keys %total_osid) { foreach my $osid (sort keys %total_osid) {
# I want undefined to mean zero!
no warnings 'uninitialized';
my ($osname, $pidofosid); my ($osname, $pidofosid);
my $user_image = 1; my $user_image = 1;
if (defined $total_osid{$osid}{failed} && $total_osid{$osid}{failed} > 0) { if ($total_osid{$osid}{failed} > 0) {
my $query_result = my $query_result =
DBQueryFatal("select osname,pid from os_info where osid='$osid'"); DBQueryFatal("select osname,pid from os_info where osid='$osid'");
...@@ -1224,31 +1227,44 @@ foreach my $osid (sort keys %total_osid) { ...@@ -1224,31 +1227,44 @@ foreach my $osid (sort keys %total_osid) {
$user_image = 0; $user_image = 0;
} }
$users_fought = 0 if !$user_image; $users_fault = 0 if !$user_image;
my %d = %{$total_osid{$osid}}; my %d = %{$total_osid{$osid}};
$summary .= "$d{failed}/$d{total} nodes with a "; $summary .= "$d{failed}/$d{total} nodes with a ";
$summary .= $user_image ? "user" : "system"; $summary .= $user_image ? "user" : "system";
$summary .= " osid of \"$osname\" failed to boot"; $summary .= " osid of \"$osname\" failed to boot";
if (defined $d{failed_nonfatal} && $d{failed_nonfatal} > 0) { if ($d{failed_nonfatal} > 0) {
my $count = ($d{failed_nonfatal} == $d{failed} my $count = ($d{failed_nonfatal} == $d{failed}
? "all" ? "all"
: "$d{failed_nonfatal}/$d{failed}"); : "$d{failed_nonfatal}/$d{failed}");
$summary .= " ($count non-fatal)"; $summary .= " ($count non-fatal)";
} }
$summary .= ":\n"; $summary .= ":\n";
my $byfailure = sub {
# I want undefined to mean zero!
my $cmp = $total_type{$osid}{$b}{failed} <=> $total_type{$osid}{$a}{failed};
return $cmp if $cmp != 0;
return $a cmp $b;
};
foreach my $type (sort keys %{$total_type{$osid}}) { foreach my $type (sort $byfailure keys %{$total_type{$osid}}) {
my %d = %{$total_type{$osid}{$type}}; my %d = %{$total_type{$osid}{$type}};
$summary .= " $d{failed}/$d{total} ${type}'s with this os failed to boot"; if ($d{failed} > 0) {
if (defined $d{failed_nonfatal} && $d{failed_nonfatal} > 0) { $summary .= " $d{failed}/$d{total} ${type}'s with this os failed to boot";
my $count = ($d{failed_nonfatal} == $d{failed} if ($d{failed_nonfatal} > 0) {
? "all" my $count = ($d{failed_nonfatal} == $d{failed}
: "$d{failed_nonfatal}/$d{failed}"); ? "all"
: "$d{failed_nonfatal}/$d{failed}");
$summary .= " ($count non-fatal)"; $summary .= " ($count non-fatal)";
}
$summary .= ".\n";
$users_fault = 0 if $d{failed} < $d{total};
} else {
$summary .= " $d{total} ";
$summary .= $d{total} == 1 ? "$type" : "$type's";
$summary .= " with this os successfully booted.\n";
} }
$summary .= ".\n";
$users_fought = 0 if $d{failed} < $d{total};
} }
} }
} }
...@@ -1257,7 +1273,7 @@ if ($failed || $failedvnodes || $failedplab) { ...@@ -1257,7 +1273,7 @@ if ($failed || $failedvnodes || $failedplab) {
push @msg, "$failed failed nodes" if $failed; push @msg, "$failed failed nodes" if $failed;
push @msg, "$failedvnodes failed virtual nodes" if $failedvnodes; push @msg, "$failedvnodes failed virtual nodes" if $failedvnodes;
push @msg, "$failedplab failed plab nodes" if $failedplab; push @msg, "$failedplab failed plab nodes" if $failedplab;
tberror ({type=>'summary', cause=>($users_fought ? 'user' : 'unknown')}, tberror ({type=>'summary', cause=>($users_fault ? 'user' : 'unknown')},
"There were ", join(', ', @msg), ".\n\n", $summary); "There were ", join(', ', @msg), ".\n\n", $summary);
} elsif ($summary) { } elsif ($summary) {
tbwarn $summary; tbwarn $summary;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment