From a239e2db534cc36aa8c3e08077383d84bf6ba8e8 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 18 Mar 2015 13:48:11 -0400 Subject: [PATCH] 5500: Add TASK_TEMPFAIL constant. shell_or_die always exits non-zero on error. --- sdk/cli/bin/crunch-job | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job index d40df908ee..b74d7af427 100755 --- a/sdk/cli/bin/crunch-job +++ b/sdk/cli/bin/crunch-job @@ -96,6 +96,7 @@ use File::Temp; use Fcntl ':flock'; use File::Path qw( make_path remove_tree ); +use constant TASK_TEMPFAIL => 111; use constant EX_TEMPFAIL => 75; $ENV{"TMPDIR"} ||= "/tmp"; @@ -1011,7 +1012,7 @@ sub reapchildren { my $temporary_fail; $temporary_fail ||= $Jobstep->{node_fail}; - $temporary_fail ||= ($exitvalue == 111); + $temporary_fail ||= ($exitvalue == TASK_TEMPFAIL); ++$thisround_failed; ++$thisround_failed_multiple if $Jobstep->{'failures'} >= 1; @@ -1831,6 +1832,8 @@ use Fcntl ':flock'; use File::Path qw( make_path remove_tree ); use POSIX qw(getcwd); +use constant TASK_TEMPFAIL => 111; + # Map SDK subdirectories to the path environments they belong to. my %SDK_ENVVARS = ("perl/lib" => "PERLLIB", "ruby/lib" => "RUBYLIB"); @@ -1878,7 +1881,7 @@ if (@ARGV) { if ((!$venv_built) and (-d $python_src) and can_run("virtualenv")) { shell_or_die(undef, "virtualenv", "--quiet", "--system-site-packages", "--python=python2.7", $venv_dir); - shell_or_die(111, "$venv_dir/bin/pip", "--quiet", "install", "-I", $python_src); + shell_or_die(TASK_TEMPFAIL, "$venv_dir/bin/pip", "--quiet", "install", "-I", $python_src); $venv_built = 1; $Log->("Built Python SDK virtualenv"); } @@ -2000,7 +2003,7 @@ sub can_run { sub shell_or_die { - my $tempfail = shift; + my $exitcode = shift; if ($ENV{"DEBUG"}) { print STDERR "@_\n"; @@ -2011,12 +2014,12 @@ sub shell_or_die my $exitstatus = sprintf("exit %d signal %d", $code >> 8, $code & 0x7f); open STDERR, ">&STDERR_ORIG"; system ("cat $destdir.log >&2"); - print STDERR "@_ failed ($err): $exitstatus"; - if ($tempfail) { - exit $tempfail; + warn "@_ failed ($err): $exitstatus"; + if (defined($exitcode)) { + exit $exitcode; } else { - exit ($code >> 8); + exit (($code >> 8) || 1); } } } -- 2.30.2