Fixed bug #57886: Errors when using different version on remote.

This commit is contained in:
Ole Tange 2020-03-22 13:50:17 +01:00
parent ab074aa198
commit 36912dc230
4 changed files with 22 additions and 14 deletions

View file

@ -23,7 +23,7 @@
use strict; use strict;
use Getopt::Long; use Getopt::Long;
$Global::progname="niceload"; $Global::progname="niceload";
$Global::version = 20200322; $Global::version = 20200323;
Getopt::Long::Configure("bundling","require_order"); Getopt::Long::Configure("bundling","require_order");
get_options_from_array(\@ARGV) || die_usage(); get_options_from_array(\@ARGV) || die_usage();
if($opt::version) { if($opt::version) {

View file

@ -2146,7 +2146,7 @@ sub check_invalid_option_combinations() {
sub init_globals() { sub init_globals() {
# Defaults: # Defaults:
$Global::version = 20200322; $Global::version = 20200323;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$::name = "GNU Parallel"; $::name = "GNU Parallel";
$Global::infinity = 2**31; $Global::infinity = 2**31;
@ -4356,9 +4356,16 @@ sub parallelized_host_filtering() {
sub sshwrapped { sub sshwrapped {
# Wrap with ssh and --env # Wrap with ssh and --env
# Return $default_value if command fails
my $sshlogin = shift; my $sshlogin = shift;
my $command = shift; my $command = shift;
my $commandline = CommandLine->new(1,[$command],{},0,0,[],[],{},{},{}); my $default_value = shift;
# wrapper that returns $default_value if the command fails:
# bug #57886: Errors when using different version on remote
# perl -e '$a=`$command`; print $? ? "$default_value" : $a'
my $wcmd = q(perl -e '$a=`).$command.q(`;).
q(print $? ? ").::pQ($default_value).q(" : $a');
my $commandline = CommandLine->new(1,[$wcmd],{},0,0,[],[],{},{},{});
my $job = Job->new($commandline); my $job = Job->new($commandline);
$job->set_sshlogin($sshlogin); $job->set_sshlogin($sshlogin);
$job->wrapped(); $job->wrapped();
@ -4370,19 +4377,18 @@ sub parallelized_host_filtering() {
if($host eq ":") { next } if($host eq ":") { next }
# The 'true' is used to get the $host out later # The 'true' is used to get the $host out later
push(@sockets, $host."\t"."true $host; ". push(@sockets, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --number-of-sockets")."\n\0"); sshwrapped($sshlogin,"parallel --number-of-sockets",0)."\n\0");
push(@cores, $host."\t"."true $host; ". push(@cores, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --number-of-cores")."\n\0"); sshwrapped($sshlogin,"parallel --number-of-cores",0)."\n\0");
push(@threads, $host."\t"."true $host; ". push(@threads, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --number-of-threads")."\n\0"); sshwrapped($sshlogin,"parallel --number-of-threads",0)."\n\0");
push(@maxline, $host."\t"."true $host; ". push(@maxline, $host."\t"."true $host; ".
sshwrapped($sshlogin,"parallel --max-line-length-allowed")."\n\0"); sshwrapped($sshlogin,"parallel --max-line-length-allowed",0)."\n\0");
# 'echo' is used to get the fastest possible ssh login time # 'echo' is used to get the fastest possible ssh login time
my $sshcmd = "true $host; exec " .$sshlogin->sshcommand()." ". my $sshcmd = "true $host; exec " .$sshlogin->sshcommand()." ".
$sshlogin->serverlogin(); $sshlogin->serverlogin();
push(@echo, $host."\t".$sshcmd." -- echo\n\0"); push(@echo, $host."\t".$sshcmd." -- echo\n\0");
} }
# --timeout 10: Setting up an SSH connection and running a simple # --timeout 10: Setting up an SSH connection and running a simple
# command should never take > 10 sec. # command should never take > 10 sec.
# --delay 0.1: If multiple sshlogins use the same proxy the delay # --delay 0.1: If multiple sshlogins use the same proxy the delay
@ -4398,6 +4404,8 @@ sub parallelized_host_filtering() {
my ($host_fh,$in,$err); my ($host_fh,$in,$err);
open3($in, $host_fh, $err, $cmd) || ::die_bug("parallel host check: $cmd"); open3($in, $host_fh, $err, $cmd) || ::die_bug("parallel host check: $cmd");
::debug("init", map { $_,"\n" } @sockets, @cores, @threads, @maxline, @echo);
if(not fork()) { if(not fork()) {
# Give the commands to run to the $cmd # Give the commands to run to the $cmd
close $host_fh; close $host_fh;

View file

@ -469,7 +469,7 @@ basename of input line.
Use the replacement string I<replace-str> instead of B<{/.}> for basename of input line without extension. Use the replacement string I<replace-str> instead of B<{/.}> for basename of input line without extension.
=item B<--bin> I<binexpr> (alpha testing) =item B<--bin> I<binexpr> (beta testing)
Use I<binexpr> as binning key and bin input to the jobs. Use I<binexpr> as binning key and bin input to the jobs.
@ -2302,7 +2302,7 @@ when called with B<--shebang>).
Use B<--sqlmaster> instead. Use B<--sqlmaster> instead.
=item B<--sqlmaster> I<DBURL> (alpha testing) =item B<--sqlmaster> I<DBURL> (beta testing)
Submit jobs via SQL server. I<DBURL> must point to a table, which will Submit jobs via SQL server. I<DBURL> must point to a table, which will
contain the same information as B<--joblog>, the values from the input contain the same information as B<--joblog>, the values from the input
@ -2340,12 +2340,12 @@ It can also be an alias from ~/.sql/aliases:
:myalias mysql:///mydb/paralleljobs :myalias mysql:///mydb/paralleljobs
=item B<--sqlandworker> I<DBURL> (alpha testing) =item B<--sqlandworker> I<DBURL> (beta testing)
Shorthand for: B<--sqlmaster> I<DBURL> B<--sqlworker> I<DBURL>. Shorthand for: B<--sqlmaster> I<DBURL> B<--sqlworker> I<DBURL>.
=item B<--sqlworker> I<DBURL> (alpha testing) =item B<--sqlworker> I<DBURL> (beta testing)
Execute jobs via SQL server. Read the input sources variables from the Execute jobs via SQL server. Read the input sources variables from the
table pointed to by I<DBURL>. The I<command> on the command line table pointed to by I<DBURL>. The I<command> on the command line

View file

@ -574,7 +574,7 @@ $Global::Initfile && unlink $Global::Initfile;
exit ($err); exit ($err);
sub parse_options { sub parse_options {
$Global::version = 20200322; $Global::version = 20200323;
$Global::progname = 'sql'; $Global::progname = 'sql';
# This must be done first as this may exec myself # This must be done first as this may exec myself