IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37187


Ignore:
Timestamp:
Aug 5, 2014, 5:03:52 PM (12 years ago)
Author:
watersc1
Message:

Updated version with the improvements at retrying.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/sc_remote_exec.pl

    r37151 r37187  
    1818my $SEC_HOST = 'mu-fe4';
    1919my $IPP_PATH = '/turquoise/usr/projects/cosmo/mswarren/ipp/';
    20 #my $remote_root  = '/scratch3/watersc1/';
    21 my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/';
    22 $remote_root = '/scratch3/watersc1/';
     20my $remote_root  = '/scratch3/watersc1/';
     21
    2322# tools
    2423my $missing_tools;
     
    3130    exit($PS_EXIT_CONFIG_ERROR);
    3231}
    33 
    3432
    3533# Options
     
    5654
    5755my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
    58 
    5956my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files                                   
    6057
     
    152149my $poll_sleep = 60;
    153150my $poll_response = 0;
     151my $poll_word  = "nothing";
     152
    154153if ($force) {
    155154    $poll_response = 1;
    156 }
    157 my $poll_word  = "nothing";
     155    $poll_word     = "Completed";
     156}
     157
    158158while (($poll_count < $poll_max)&&($poll_response != 1)&&($poll_response != -1)&&($force != 1)) {
    159159    if ($verbose) {
     
    171171        warn("The job exited incorrectly: $remote_id $job_id $poll_word.  Attempting to recover what we can.");
    172172        $poll_response = 1; # To fool the check later into proceding
    173 #       &my_die("The job exited incorrectly.",$remote_id, $PS_EXIT_PROG_ERROR);
    174173    }
    175174    $poll_count++;
     
    181180    &my_die("Job hasn't completed.  Ending polling.", $remote_id, 0, "run", $job_id);
    182181}
    183 # Retrieve validation summary
    184 my $fault = 0;
     182
    185183
    186184# Initialize the remote side to sync things
     
    193191#scp_get($remote_return,$ipp_return);
    194192
    195 # Check to see if we can resume.  Pack the files into an array
     193# Construct list of dbinfo files we'll need to execute.
    196194my @returned_files = ();
    197195my @dbinfo_files   = ();
     
    211209close(RETURN);
    212210print STDERR "Expect $#dbinfo_files dbinfo files\n";
    213 # Binary search it.  BUT: We're binary searching binary values.  So,
    214 # this has to be far more careful than a fully sorted case would be.
    215 # Only scan the dbinfo files as those are the things that are
    216 # generated after the processing, and so must be the last things to
    217 # exist.
    218211
    219212my $first = 0;
     
    222215my $range = 20;  # How wide of a chunk to look through to catch threading drops
    223216my $offset = 0;  # Offset to start from.
    224 # This doesn't work as well as I'd like, and with the rsync, it's less needed.
    225 # if (( stat($dbinfo_files[$last]) )[7] != 0) { $offset = $#dbinfo_files;}
    226 # else {
    227 #     my $count = 0;
    228 #     while ($first < $last - $range) {
    229 
    230 #       $mid = int(($last + $first)/2);
    231 #       for (my $i = 0; $i <= $range; $i++) {
    232 #           my $size = (stat($dbinfo_files[$mid + $i]))[7];
    233 # #         print STDERR "$first $last $mid $i $size $dbinfo_files[$mid + $i]\n";
    234 #           if ($size == 0) {
    235 #               if ($last == $mid + $i) {
    236 #                   $first = $last - 1;
    237 #               }
    238 #               $last = $mid + $i;
    239 #               $i = $range + 10;
    240 #           }
    241 #       }
    242 #       if ($last > $mid + $range) { $first = $mid + $range; }
    243 #       $count++;
    244 #       if ($count > 200) {
    245 #           &my_die("The iteration loop couldn't converge after 200 rounds, suggesting something has gone wrong.",
    246 #                   $remote_id,4,"error_run");
    247 #       }
    248 #     }
    249 #     $offset = $mid - $range; # Because I want to make sure I get to the beginning of the thread group.
    250 #     $offset = $dbindex[$offset]; # Because we need to convert from dbinfo space to returned file space.
    251 # }
    252 
    253 # Feed teh return list into the transfer tool
     217
     218# Feed the return list into the transfer tool
    254219# If this fails, we should go to an auth wait point.
    255 if ($poll_word eq 'Completed') {
     220if ($poll_word eq 'Completed') { 
     221    # We're complete.  All files should exist on disk
    256222    my $iter = 0;
    257223    my $transfer_success = 1;
     
    267233}
    268234else {
     235    # Just try and fetch things, because we didn't complete correctly, it seems.
    269236    my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_return --offset $offset");
    270237    my $return_push_output_print = join "\n", @{ $return_push_output };
     
    282249        run(command => $cmd, verbose => $verbose);
    283250    unless ($success) {
     251
    284252        # This shouldn't fail, but we also can't suddenly abort if something does fail. 
    285253        # Now we're going to drop the component that owns this dbinfo, which should force a retry.
    286254        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    287255        warn("The command that shouldn't fail has failed: $file $cmd $remote_id $error_code");
    288         drop_component($remote_id,$cmd,$file);
     256        if ($poll_word ne 'Completed') {  # If the job claims it completed, then we're fighting the network.
     257            drop_component($remote_id,$cmd,$file);
     258        }
    289259    }
    290260
     
    342312    my $cmd = shift;
    343313    $cmd = "$ssh  $DMZ_HOST ssh  ${SEC_HOST} $cmd";
     314    print "EXEC: $cmd\n";
    344315    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    345316        run(command => $cmd, verbose => $verbose);
Note: See TracChangeset for help on using the changeset viewer.