IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37288


Ignore:
Timestamp:
Aug 22, 2014, 11:04:42 AM (12 years ago)
Author:
eugene
Message:

sc_remote_poll basically complete and untested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-pv3-20140717/ippScripts/scripts/sc_remote_poll.pl

    r37286 r37288  
    6767    defined($job_id);
    6868
    69 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
     69my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id);
    7070my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7171
     
    8787    unless ($success) {
    8888        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    89         &my_die("Unable to run remotetool to determine remote run status", $remote_id,$error_code);
     89        &my_die("Unable to run remotetool to determine remote run status", $remote_id, $error_code);
    9090    }
    9191
     
    9494
    9595    my $metadata = parse_md_list($MDlist);
    96     $runData = $rrData2->[0]; # There should be only one
    97 }
    98 
    99 # Poll the job status?
     96    $runData = $metadata->[0]; # There should be only one
     97}
     98
     99# STEP 3: Poll the job status
    100100my $poll_response = 0;
    101101my $poll_word  = "nothing";
     
    114114}
    115115
    116 # Initialize the remote side to sync things
    117 my $uri_return = $path_base . ".return";
    118 my ($ipp_return, $remote_return) = uri_convert($uri_return);
     116my $remote_path = uri_local_to_remote($path_base);
    119117
    120118# transfer tool should check the existence of files on the remote end
     
    128126        $iter++;
    129127        check_ssh_connection();
    130         my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_return --offset $offset");
     128        my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_path --offset $offset");
    131129        my $return_push_output_print = join "\n", @{ $return_push_output };
    132130        if ($return_push_output_print =~ /exited with value 255/) { $transfer_success = 0; }
     
    134132    } while (($transfer_success != 1) &&  ($iter < 10));  # Try harder;
    135133
    136     if (!$transfer_success) { &my_die ("failed to get all return files"); }
    137 }
    138 print STDERR "rsync of all files is complete, updating gpc1 database\n";
     134    if (!$transfer_success) { &my_die ("failed to get all return files", $remote_id, 23); }
     135}
     136print STDERR "rsync of all files is complete, checking the results\n";
     137
     138# grab the .stats file
     139
     140my $uri_stats    = $path_base . ".stats";
     141my $disk_stats   = $ipprc->file_resolve($uri_stats);
     142my $remote_stats = uri_local_to_remote($uri_stats);
     143
     144scp_get($remote_stats,$disk_stats);
     145
     146# check for PASS / PART / FAIL : if dbinfo is PASS, go ahead and execute that. 
     147
     148my $Npass = 0;
     149my $Npart = 0;
     150my $Nfail = 0;
     151my @dbinfo_files   = ();
     152open (STATFILE, "$disk_stats") || &my_die("Couldn't open file? $disk_stats", $remote_id, $PS_EXIT_SYS_ERROR);
     153while (my $line = <RETURN>) {
     154    chomp $line;
     155    unless ($_ =~ /dbinfo/) { next; }
     156
     157    my @words = split (" ", $line);
     158    if ($words[1] eq "PASS") {
     159        push @dbinfo_files, $words[0];
     160        $Npass ++;
     161    } elsif ($words[1] eq "FAIL") {
     162        $Nfail ++;
     163    } elsif ($words[1] eq "PART") {
     164        $Npart ++;
     165    }
     166}
     167close(RETURN);
     168print STDERR "dbinfo files: $Npass PASS, $Nfail FAIL, $Npart PART\n";
    139169
    140170foreach my $file (@dbinfo_files) {
     
    143173    close(DBF);
    144174    chomp($cmd);
    145 #    print STDERR "$file $cmd\n";
     175
    146176    $cmd =~ s/-/ -/g; # This is just a safety check for missing space.
     177
     178    if ($cmd == "") {
     179        print STDERR "problem: empty dbinfo file\n";
     180        next;
     181    }
     182
    147183    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    148184        run(command => $cmd, verbose => $verbose);
    149185    unless ($success) {
    150 
    151186        # This shouldn't fail, but we also can't suddenly abort if something does fail.
    152187        # Now we're going to drop the component that owns this dbinfo, which should force a retry.
     
    154189        warn("The command that shouldn't fail has failed: $file $cmd $remote_id $error_code");
    155190        if ($poll_word ne 'Completed') {  # If the job claims it completed, then we're fighting the network.
    156             drop_component($remote_id,$cmd,$file);
     191            fail_component($remote_id, $cmd, $file);
    157192        }
    158193    }
     
    161196
    162197# We're done, so set the state and exit.
    163 &my_die("Finished",$remote_id,0,"full");
    164 
     198&my_die("Finished", $remote_id, 0, "full");
    165199
    166200# END PROGRAM
    167 
    168201
    169202sub check_ssh_connection {
     
    289322
    290323    return($local_uri);
     324}
     325
     326sub fail_component {
     327    my $remote_id = shift;
     328    my $cmd = shift;
     329    my $file = shift;
     330
     331    # Steal the stage_id from the filename.  This isn't something I'm happy about.
     332    my $stage = $runData->{stage};
     333    my $stage_id = $file;
     334    if ($stage eq 'chip') {
     335        $stage_id =~ s/^.*ch\.//;
     336    }
     337    elsif ($stage eq 'camera') {
     338        $stage_id =~ s/^.*cm\.//;
     339    }
     340    elsif ($stage eq 'warp') {
     341        $stage_id =~ s/^.*wrp\.//;
     342    }
     343    elsif ($stage eq 'stack') {
     344        $stage_id =~ s/^.*stk\.//;
     345    }
     346    $stage_id =~ s/\..*$//;
     347   
     348    print STDERR "failed component: $remote_id, $stage_id\n";
     349   
     350    # Drop this from the database
     351    ## my $drop_cmd = "$remotetool -dropcomponent -remote_id $remote_id -stage_id $stage_id ";
     352    ## $drop_cmd   .= " -dbname $dbname " if defined($dbname);
     353    ## system($drop_cmd);
    291354}
    292355
     
    329392    my $exit_code = shift;
    330393    my $exit_state = shift;
    331     my $jobid = shift;
     394
    332395    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
    333396
Note: See TracChangeset for help on using the changeset viewer.