Handle case where chromite dir is missing.
Right now cbuildbot uses cros_sdk before we've even updated the Chrome
OS source code. This can cause issues if the old version of cros_sdk
is missing or corrupted.
Fortunately, we already unmount the directories ourselves, so it is
safe for us to just rm -rf the dir.
BUG=chromium:258167
TEST=Run trybot run on machine with missing chromite dir.
TEST=Run a bunch of trybot runs including stop build runs.
Change-Id: I2b7d87588dafbac937e114225091c877702bd62c
Reviewed-on: https://gerrit.chromium.org/gerrit/61373
Reviewed-by: Matt Tennant <mtennant@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/buildbot/cbuildbot_stages.py b/buildbot/cbuildbot_stages.py
index f57b60a..c4b96c5 100644
--- a/buildbot/cbuildbot_stages.py
+++ b/buildbot/cbuildbot_stages.py
@@ -229,9 +229,11 @@
def _DeleteChroot(self):
chroot = os.path.join(self._build_root, constants.DEFAULT_CHROOT_DIR)
if os.path.exists(chroot):
- cros_build_lib.RunCommand(['cros_sdk', '--delete', '--chroot', chroot],
- self._build_root,
- cwd=self._build_root)
+ # At this stage, it's not safe to run the cros_sdk inside the buildroot
+ # itself because we haven't sync'd yet, and the version of the chromite
+ # in there might be broken. Since we've already unmounted everything in
+ # there, we can just remove it using rm -rf.
+ osutils.RmDir(chroot, ignore_missing=True, sudo=True)
def _DeleteArchivedTrybotImages(self):
"""For trybots, clear all previus archive images to save space."""
@@ -267,13 +269,13 @@
cros_build_lib.Warning("ManifestCheckout at %s is unusable: %s",
self._build_root, e)
+ # Clean mount points first to be safe about deleting.
+ commands.CleanUpMountPoints(self._build_root)
+
if manifest is None:
self._DeleteChroot()
repository.ClearBuildRoot(self._build_root, self._options.preserve_paths)
else:
- # Clean mount points first to be safe about deleting.
- commands.CleanUpMountPoints(self._build_root)
-
commands.BuildRootGitCleanup(self._build_root, self._options.debug)
tasks = [functools.partial(commands.BuildRootGitCleanup,
self._build_root, self._options.debug),