Add more protection to CleanStage from bad manifests.

Have CleanStage catch most exceptions generated by parsing the
manifest instead of just EnvironmentError.

TEST=Verified manifest parse error leads to buildroot clobber.

Change-Id: I90679e8a8fae62d8bb9601ad9cc6c9d9e42bdaee
Reviewed-by: Brian Harring <>
Commit-Ready: Ryan Cui <>
Tested-by: Ryan Cui <>
Reviewed-by: David James <>
diff --git a/buildbot/ b/buildbot/
index fe063e0..63f9372 100644
--- a/buildbot/
+++ b/buildbot/
@@ -116,10 +116,16 @@
         manifest = cros_build_lib.ManifestCheckout.Cached(self._build_root,
-      except EnvironmentError:
-        # Either there is no repo there, or the manifest isn't usable; either
-        # way, clean it up.
-        pass
+      except (KeyboardInterrupt, MemoryError, SystemExit):
+        raise
+      except Exception, e:
+        # Either there is no repo there, or the manifest isn't usable.  If the
+        # directory exists, log the exception for debugging reasons.  Either
+        # way, the checkout needs to be wiped since it's in an unknown
+        # state.
+        if os.path.exists(self._build_root):
+          cros_build_lib.Warning("ManifestCheckout at %s is unusable: %s",
+                                 self._build_root, e)
     if manifest is None: