parallel: Fixed bug #62672: Triggered a bug with --filter-host

This commit is contained in:
Ole Tange 2022-08-06 22:27:52 +02:00
parent 2849adb34d
commit b74f2d5629
3 changed files with 43 additions and 27 deletions

View file

@ -4854,32 +4854,37 @@ sub filter_hosts() {
$Global::minimal_command_line_length = 100_000_000; $Global::minimal_command_line_length = 100_000_000;
while (my ($string, $sshlogin) = each %Global::host) { while (my ($string, $sshlogin) = each %Global::host) {
if($sshlogin->local()) { next } if($sshlogin->local()) { next }
$nsockets_ref->{$string} or my ($nsockets,$ncores,$nthreads,$time_to_login,$maxlen) =
::die_bug("nsockets missing: $string"); ($nsockets_ref->{$string},$ncores_ref->{$string},
$ncores_ref->{$string} or $nthreads_ref->{$string},$time_to_login_ref->{$string},
::die_bug("ncores missing: $string"); $maxlen_ref->{$string});
$nthreads_ref->{$string} or defined $nsockets or ::die_bug("nsockets missing: $string");
::die_bug("nthreads missing: $string"); defined $ncores or ::die_bug("ncores missing: $string");
$time_to_login_ref->{$string} or defined $nthreads or ::die_bug("nthreads missing: $string");
::die_bug("time_to_login missing: $string"); defined $time_to_login or ::die_bug("time_to_login missing: $string");
$maxlen_ref->{$string} or defined $maxlen or ::die_bug("maxlen missing: $string");
::die_bug("maxlen missing: ".$sshlogin->string()); # ncpus may be set by 4/hostname
$sshlogin->set_ncpus($nthreads_ref->{$string}); my $ncpus = $sshlogin->ncpus();
# $nthreads may be 0 if GNU Parallel is not installed remotely
$ncpus = $nthreads || $ncpus;
if($opt::use_cpus_instead_of_cores) { if($opt::use_cpus_instead_of_cores) {
$sshlogin->set_ncpus($ncores_ref->{$string}); $ncpus = $ncores || $ncpus;
} elsif($opt::use_sockets_instead_of_threads) { } elsif($opt::use_sockets_instead_of_threads) {
$sshlogin->set_ncpus($nsockets_ref->{$string}); $ncpus = $nsockets || $ncpus;
} elsif($opt::use_cores_instead_of_threads) { } elsif($opt::use_cores_instead_of_threads) {
$sshlogin->set_ncpus($ncores_ref->{$string}); $ncpus = $ncores || $ncpus;
} }
$sshlogin->set_time_to_login($time_to_login_ref->{$string}); $sshlogin->set_ncpus($ncpus);
$sshlogin->set_maxlength($maxlen_ref->{$string}); $sshlogin->set_time_to_login($time_to_login);
$maxlen = $maxlen || Limits::Command::max_length();
$sshlogin->set_maxlength($maxlen);
::debug("init", "Timing from -S:$string ", ::debug("init", "Timing from -S:$string ",
" nsockets:",$nsockets_ref->{$string}, " ncpus:", $ncpus,
" ncores:", $ncores_ref->{$string}, " nsockets:",$nsockets,
" nthreads:",$nthreads_ref->{$string}, " ncores:", $ncores,
" time_to_login:", $time_to_login_ref->{$string}, " nthreads:",$nthreads,
" maxlen:", $maxlen_ref->{$string}, " time_to_login:", $time_to_login,
" maxlen:", $maxlen,
" min_max_len:", $Global::minimal_command_line_length,"\n"); " min_max_len:", $Global::minimal_command_line_length,"\n");
} }
} }
@ -4951,15 +4956,15 @@ sub parse_host_filtering() {
if(/parallel: Warning: Cannot figure out number of/) { if(/parallel: Warning: Cannot figure out number of/) {
next; next;
} }
if(not $nsockets{$col[0]}) { if(not defined $nsockets{$col[0]}) {
$nsockets{$col[0]} = $col[1]; $nsockets{$col[0]} = $col[1];
} elsif(not $ncores{$col[0]}) { } elsif(not defined $ncores{$col[0]}) {
$ncores{$col[0]} = $col[1]; $ncores{$col[0]} = $col[1];
} elsif(not $nthreads{$col[0]}) { } elsif(not defined $nthreads{$col[0]}) {
$nthreads{$col[0]} = $col[1]; $nthreads{$col[0]} = $col[1];
} elsif(not $maxlen{$col[0]}) { } elsif(not defined $maxlen{$col[0]}) {
$maxlen{$col[0]} = $col[1]; $maxlen{$col[0]} = $col[1];
} elsif(not $echo{$col[0]}) { } elsif(not defined $echo{$col[0]}) {
$echo{$col[0]} = $col[1]; $echo{$col[0]} = $col[1];
} elsif(m/perl: warning:|LANGUAGE =|LC_ALL =|LANG =|are supported and installed|Disconnected from|Received disconnect from/) { } elsif(m/perl: warning:|LANGUAGE =|LC_ALL =|LANG =|are supported and installed|Disconnected from|Received disconnect from/) {
# Skip these: # Skip these:
@ -5004,7 +5009,7 @@ sub parallelized_host_filtering() {
# bug #57886: Errors when using different version on remote # bug #57886: Errors when using different version on remote
# perl -e '$a=`$command`; print $? ? "$default_value" : $a' # perl -e '$a=`$command`; print $? ? "$default_value" : $a'
my $wcmd = q(perl -e '$a=`).$command.q(`;). my $wcmd = q(perl -e '$a=`).$command.q(`;).
q(print $? ? ").::pQ($default_value).q(" : $a'); q(print $? ? ").::pQ($default_value."\n").q(" : $a');
my $commandline = CommandLine->new(1,[$wcmd],{},0,0,[],[],[],[],{},{}); 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);

View file

@ -209,6 +209,12 @@ par_PARALLEL_SSHLOGIN_SSHHOST() {
LANG=C sort LANG=C sort
} }
par_filter_hosts_parallel_not_installed() {
echo 'bug #62672: Triggered a bug with --filter-host'
parallel -S nopathbash@lo --filter-hosts echo ::: OK
parallel --nonall -S nopathbash@lo --filter-hosts echo OK
}
par_d_filter_hosts() { par_d_filter_hosts() {
echo '### --filter-hosts and -0' echo '### --filter-hosts and -0'
echo '### https://lists.gnu.org/archive/html/parallel/2022-07/msg00002.html' echo '### https://lists.gnu.org/archive/html/parallel/2022-07/msg00002.html'

View file

@ -97,6 +97,11 @@ par_ksh_embed Put your code here
par_ksh_embed You can also activate GNU Parallel for interactive use by: par_ksh_embed You can also activate GNU Parallel for interactive use by:
par_ksh_embed . ./parallel-embed par_ksh_embed . ./parallel-embed
par_fish_embed Not implemented par_fish_embed Not implemented
par_filter_hosts_parallel_not_installed bug #62672: Triggered a bug with --filter-host
par_filter_hosts_parallel_not_installed parallel: Warning: Could not figure out number of cpus on nopathbash@lo (). Using 1.
par_filter_hosts_parallel_not_installed OK
par_filter_hosts_parallel_not_installed parallel: Warning: Could not figure out number of cpus on nopathbash@lo (). Using 1.
par_filter_hosts_parallel_not_installed OK
par_env_parallel_big_env ### bug #54128: command too long when exporting big env par_env_parallel_big_env ### bug #54128: command too long when exporting big env
par_env_parallel_big_env should not fail par_env_parallel_big_env should not fail
par_env_parallel_big_env OK par_env_parallel_big_env OK