2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-09-09 22:46:44 +00:00

fix(xcat-dep): record a worker the kernel killed as failed

A child killed by a signal leaves 0 in the high byte of its wait status. The
per-codename worker loop read only that byte, so a cancelled or OOM-killed
codename was counted as built, and the run could reach validation with the
staging tree that worker never finished.

One helper decodes a wait status for both the worker loop and run_bounded, and
reports 128 plus the signal for a child the kernel killed.
This commit is contained in:
Vinícius Ferrão
2026-09-06 15:39:03 -03:00
parent 22c26a5d57
commit ccbf05e758
2 changed files with 15 additions and 3 deletions
+11 -2
View File
@@ -22,6 +22,7 @@ our @EXPORT_OK = qw(
every_step_failed
forward_signals_to_workers
block_handled_signals
exit_status
restore_signal_mask
hashes_equal
print_step
@@ -202,6 +203,15 @@ sub stall_report {
return $total;
}
# exit_status($status): the exit code of a waited-for child, or 128 plus the signal that killed it.
# A child killed by a signal has 0 in the high byte, so reading only that byte reports a build the
# kernel terminated as a build that succeeded.
sub exit_status {
my ($status) = @_;
return 0 unless defined $status;
return ($status & 127) ? 128 + ($status & 127) : $status >> 8;
}
# block_handled_signals(): block INT, TERM and HUP and return the previous mask, for the window
# between forking a child and being able to signal it. A cancellation arriving in that window would
# otherwise kill the parent under a handler that does not know the child yet, and the child would
@@ -323,8 +333,7 @@ sub run_bounded {
return { ec => 124, timed_out => 1, elapsed => time - $t0 };
}
my $ec = ($status & 127) ? 128 + ($status & 127) : $status >> 8;
return { ec => $ec, timed_out => 0, elapsed => time - $t0 };
return { ec => exit_status($status), timed_out => 0, elapsed => time - $t0 };
}
sub display_quote {
+4 -1
View File
@@ -662,7 +662,10 @@ sub build_deps {
}
my $pid = wait();
if ($pid > 0) {
my $ec = $? >> 8;
# A worker the kernel killed leaves 0 in the high byte, so the shifted status alone
# would record a cancelled or OOM-killed codename as built.
require XCAT::BuildUtils;
my $ec = XCAT::BuildUtils::exit_status($?);
my $cn = delete $pid2cn{$pid} // '?';
$fail{$cn} = $ec if $ec != 0;
$running--;