Index: /trunk/ippScripts/scripts/ipp_cleanup.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_cleanup.pl	(revision 35464)
+++ /trunk/ippScripts/scripts/ipp_cleanup.pl	(revision 35465)
@@ -20,4 +20,12 @@
 my ($stage, $camera, $stage_id, $mode, $path_base, $dbname, $verbose, $no_op, $helplist, $logfile, $check_all);
 my $very_verbose = 0;
+
+# turn this on to set data_state to error_state for components for which cleanup fails
+# Note: we no longer do this, we leave the state alone.
+my $set_error_state_for_file = 0;
+
+# turn this on the set the state to error_state when errors occur cleaning up individual components
+# We may stop doing this
+my $set_error_state_for_run = 1;
 
 # this gets set to 1 the first time we set the corresponding destreak run to be cleaned
@@ -335,30 +343,38 @@
             $num_errors++;
 
-            # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
-            my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
-            $command .= " -dbname $dbname" if defined $dbname;
-
-            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            if ($set_error_state_for_file) {
+                # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
+                my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
+                $command .= " -dbname $dbname" if defined $dbname;
+
+                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                        run(command => $command, verbose => $verbose);
+                unless ($success) {
+                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                    &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
+                }
+            }
+
+            if ($set_error_state_for_run) {
+                # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
+                $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state";
+                $command .= " -dbname $dbname" if defined $dbname;
+
+                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
                     run(command => $command, verbose => $verbose);
-            unless ($success) {
-                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
-            }
-
-            # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
-            $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state";
-            $command .= " -dbname $dbname" if defined $dbname;
-
-            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-                run(command => $command, verbose => $verbose);
-            unless ($success) {
-                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
-            }
-
-        }
-    }
-    if ($num_updated eq 0 and $num_errors eq 0) {
-        # no chips were updated by this procedssing so set state to $done_state
+                unless ($success) {
+                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                    &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
+                }
+
+            }
+        }
+    }
+    # We no longer depend on chiptool to promote the run from goto_cleaned to cleaned based on all of
+    # the imfiles being in the cleaned state.
+    # Due to missing files we don't always clean individual components.
+    # unless there was an error set state to $done_state
+    if (!$set_error_state_for_run or $num_errors eq 0) {
+        # set state to $done_state
         my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $done_state";
         $command .= " -dbname $dbname" if defined $dbname;
@@ -625,28 +641,32 @@
          } else {
             $num_errors++;
-            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
-            $command .= " -dbname $dbname" if defined $dbname;
-
-            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-                run(command => $command, verbose => $verbose);
-            unless ($success) {
-                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
-            }
-
-            # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
-            $command = "$warptool -warp_id $stage_id -updaterun -set_state $error_state";
-            $command .= " -dbname $dbname" if defined $dbname;
-
-            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-                run(command => $command, verbose => $verbose);
-            unless ($success) {
-                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
-            }
-        }
-    }
-    if ($num_updated eq 0 and $num_errors eq 0) {
-        # no skycells were updated by this procedssing so set state to $done_state
+            if ($set_error_state_for_file) {
+                my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
+                $command .= " -dbname $dbname" if defined $dbname;
+
+                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                    run(command => $command, verbose => $verbose);
+                unless ($success) {
+                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                    &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
+                }
+            }
+
+            if ($set_error_state_for_run) {
+                # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
+                $command = "$warptool -warp_id $stage_id -updaterun -set_state $error_state";
+                $command .= " -dbname $dbname" if defined $dbname;
+
+                ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                    run(command => $command, verbose => $verbose);
+                unless ($success) {
+                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                    &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
+                }
+            }
+        }
+    }
+    if (!$set_error_state_for_run or $num_errors eq 0) {
+        # Set run to done state
         my $command = "$warptool -warp_id $stage_id -updaterun -set_state $done_state";
         $command .= " -dbname $dbname" if defined $dbname;
