IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 10, 2013, 9:55:17 AM (13 years ago)
Author:
bills
Message:

in chip stage cleanup, if censorObjects faults when checking the smf file,
do not raise an error instead treat the smf as bad and do not clean the
chip stage cmf files.
Improved error handling in cleanup of bg stages

File:
1 edited

Legend:

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

    r35465 r35787  
    202202                print STDERR "\nSTDOUT:\n" . join "", @$stdout_buf;
    203203                print STDERR "\nSTDERR:\n" . join "", @$stderr_buf;
    204                 &my_die("Unable to perform censorObjects -checkinputonly: $error_code", "chip", $stage_id, $error_code);
     204                # smf file is probably corrupt. Carry on. We will not clean sources unless another good smf is found
     205                # &my_die("Unable to perform censorObjects -checkinputonly: $error_code", "chip", $stage_id, $error_code);
     206                next;
    205207            }
    206208            $good_smf++;
     
    374376    # the imfiles being in the cleaned state.
    375377    # Due to missing files we don't always clean individual components.
    376     # unless there was an error set state to $done_state
     378    # So unless there was an error set state to $done_state
    377379    if (!$set_error_state_for_run or $num_errors eq 0) {
    378380        # set state to $done_state
     
    19161918    }
    19171919
    1918     # XXX: Is not having any files to process really a bug?
    1919     if (@$stdout_buf == 0)  {
     1920    # XXX: Is not having any files to process really a bug? NO
     1921    if (0 and @$stdout_buf == 0)  {
    19201922        my $command = "$bgtool -chip_bg_id $stage_id -updatechip -set_state $error_state";
    19211923        $command .= " -dbname $dbname" if defined $dbname;
     
    19351937
    19361938    # loop over all of the imfiles, determine the path_base and class_id for each
     1939    my $num_errors = 0;
     1940    my $num_updated = 0;
    19371941    foreach my $imfile (@$imfiles) {
    19381942        my $class_id = $imfile->{class_id};
     
    19891993
    19901994        if ($status)  {
     1995            $num_updated++;
    19911996            my $command = "$bgtool -chip_bg_id $stage_id -class_id $class_id";
    19921997            if ($mode eq "goto_cleaned") {
     
    20102015
    20112016        } else {
    2012 
    2013             # if an error happens for one chip, the chipBackgroundRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
    2014             my $command = "$bgtool -updatechipimfile -chip_bg_id $stage_id -class_id $class_id -set_data_state $error_state";
    2015             $command .= " -dbname $dbname" if defined $dbname;
    2016 
    2017             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2017            $num_errors++;
     2018
     2019            if ($set_error_state_for_file) {
     2020                # if an error happens for one chip, the chipBackgroundRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
     2021                my $command = "$bgtool -updatechipimfile -chip_bg_id $stage_id -class_id $class_id -set_data_state $error_state";
     2022                $command .= " -dbname $dbname" if defined $dbname;
     2023
     2024                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2025                        run(command => $command, verbose => $verbose);
     2026                unless ($success) {
     2027                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2028                    &my_die("Unable to perform bgtool: $error_code", "chip_bg", $stage_id, $error_code);
     2029                }
     2030            }
     2031            if ($set_error_state_for_run) {
     2032
     2033                # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
     2034                $command = "$bgtool -chip_bg_id $stage_id -updatechip -set_state $error_state";
     2035                $command .= " -dbname $dbname" if defined $dbname;
     2036
     2037                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    20182038                    run(command => $command, verbose => $verbose);
    2019             unless ($success) {
    2020                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    2021                 &my_die("Unable to perform bgtool: $error_code", "chip_bg", $stage_id, $error_code);
    2022             }
    2023 
    2024             # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
    2025             $command = "$bgtool -chip_bg_id $stage_id -updatechip -set_state $error_state";
    2026             $command .= " -dbname $dbname" if defined $dbname;
    2027 
    2028             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    2029                 run(command => $command, verbose => $verbose);
    2030             unless ($success) {
    2031                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    2032                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    2033             }
    2034 
    2035         }
    2036     }
     2039                unless ($success) {
     2040                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2041                    &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     2042                }
     2043
     2044            }
     2045        }
     2046    }
     2047    if (!$set_error_state_for_run or ($num_errors eq 0)) {
     2048        # Set run to done state
     2049        my $command = "$bgtool -chip_bg_id $stage_id -updatechip -set_state $done_state";
     2050        $command .= " -dbname $dbname" if defined $dbname;
     2051
     2052        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2053            run(command => $command, verbose => $verbose);
     2054        unless ($success) {
     2055            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2056            &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     2057        }
     2058    }
     2059    print "Cleanup completed for chip_bg_id $stage_id. num_updated: $num_updated";
     2060    print " num_errors:  $num_errors" if $num_errors;
     2061    print "\n";
    20372062    exit 0;
    20382063}
     
    20602085    }
    20612086
    2062     # XXX: Is not having any files to process really a bug?
    2063     if (@$stdout_buf == 0)  {
     2087    # XXX: Is not having any files to process really a bug? NO
     2088    if (0 and @$stdout_buf == 0)  {
    20642089        my $command = "$bgtool -warp_bg_id $stage_id -updatewarp -set_state $error_state";
    20652090        $command .= " -dbname $dbname" if defined $dbname;
     
    20792104
    20802105    # loop over all of the imfiles, determine the path_base and skycell_id for each
     2106    my $num_errors = 0;
     2107    my $num_updated = 0;
    20812108    foreach my $imfile (@$imfiles) {
    20822109        my $skycell_id = $imfile->{skycell_id};
     
    20962123                        print STDERR "forcing cleanup for warpBackgroundSkyfile $stage_id $skycell_id "
    20972124                            . " because config file ($config_file) is gone\n";
     2125                    } elsif ($imfile->{fault}) {
     2126                        print STDERR "forcing cleanup for faulted warpBackgroundSkyfile\n";
    20982127                    } else {
    20992128                        print STDERR "skipping cleanup for warpBackgroundSkyfile $stage_id $skycell_id "
     
    21032132                }
    21042133            }
    2105             elsif ($mode eq "goto_scrubbed") {
    2106                 my $config_file = $ipprc->filename("PSWARP.CONFIG", $path_base, $skycell_id);
    2107 
    2108                 if ($ipprc->file_exists($config_file)) {
    2109                     print STDERR "skipping scrubbed for chipBackgroundRun $stage_id $skycell_id "
    2110                         . " because config file ($config_file) is present\n";
    2111                     $status = 0;
    2112                 }
    2113             }
    21142134        }
    21152135
     
    21332153
    21342154        if ($status)  {
     2155            $num_updated++;
    21352156            my $command = "$bgtool -warp_bg_id $stage_id -skycell_id $skycell_id";
    21362157            # recall that only goto_cleaned is supported (currently)
     
    21562177        } else {
    21572178
    2158             # if an error happens for one skycell, the warpBackgroundRun will stay in goto_*, but the skycells will go to error_* (matching the goto_*)
    2159             my $command = "$bgtool -updatewarpskyfile -warp_bg_id $stage_id -skycell_id $skycell_id -set_state $error_state";
    2160             $command .= " -dbname $dbname" if defined $dbname;
    2161 
    2162             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2179          $num_errors++;
     2180
     2181          # NOTE: bgtool does not support -updatewarpskyfile
     2182            if (0) {
     2183                # if an error happens for one skycell, the warpBackgroundRun will stay in goto_*, but the skycells will go to error_* (matching the goto_*)
     2184                my $command = "$bgtool -updatewarpskyfile -warp_bg_id $stage_id -skycell_id $skycell_id -set_state $error_state";
     2185                $command .= " -dbname $dbname" if defined $dbname;
     2186
     2187                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2188                        run(command => $command, verbose => $verbose);
     2189                unless ($success) {
     2190                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2191                    &my_die("Unable to perform bgtool: $error_code", "warp_bg", $stage_id, $error_code);
     2192                }
     2193            }
     2194
     2195            if ($set_error_state_for_run) {
     2196
     2197                # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
     2198                $command = "$bgtool -warp_bg_id $stage_id -updatewarp -set_state $error_state";
     2199                $command .= " -dbname $dbname" if defined $dbname;
     2200
     2201                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    21632202                    run(command => $command, verbose => $verbose);
    2164             unless ($success) {
    2165                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    2166                 &my_die("Unable to perform bgtool: $error_code", "warp_bg", $stage_id, $error_code);
    2167             }
    2168 
    2169             # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
    2170             $command = "$bgtool -warp_bg_id $stage_id -updatewarp -set_state $error_state";
    2171             $command .= " -dbname $dbname" if defined $dbname;
    2172 
    2173             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    2174                 run(command => $command, verbose => $verbose);
    2175             unless ($success) {
    2176                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    2177                 &my_die("Unable to perform bgtool: $error_code", "warp", $stage_id, $error_code);
    2178             }
    2179         }
    2180     }
     2203                unless ($success) {
     2204                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2205                    &my_die("Unable to perform bgtool: $error_code", "warp", $stage_id, $error_code);
     2206                }
     2207            }
     2208        }
     2209    }
     2210    if (($num_errors == 0) || !$set_error_state_for_run) {
     2211        # Set run to done state
     2212        my $command = "$bgtool -warp_bg_id $stage_id -updatewarp -set_state $done_state";
     2213        $command .= " -dbname $dbname" if defined $dbname;
     2214
     2215        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     2216            run(command => $command, verbose => $verbose);
     2217        unless ($success) {
     2218            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     2219            &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     2220        }
     2221    }
     2222    print "Cleanup completed for warp_bg_id $stage_id. num_updated: $num_updated";
     2223    print " num_errors:  $num_errors" if $num_errors;
     2224    print "\n";
    21812225    exit 0;
    21822226}
Note: See TracChangeset for help on using the changeset viewer.