mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 15:11:19 +02:00
Change preflight cleanup process to always be run before any run and add lazy unmount before every run.
Change-Id: If7db175f828fccdd4caa342a0370e842503f16dc BUG=8015 TEST=Ran it with cbuildbot with/without --clobber with/without old state. Review URL: http://codereview.chromium.org/4007005
This commit is contained in:
parent
676dff53cf
commit
dcd1de0bb9
@ -218,8 +218,41 @@ def _GetVMConstants(buildroot):
|
|||||||
return (vdisk_size.strip(), statefulfs_size.strip())
|
return (vdisk_size.strip(), statefulfs_size.strip())
|
||||||
|
|
||||||
|
|
||||||
|
def _GitCleanup(buildroot):
|
||||||
|
"""Clean up git branch after previous uprev attempt."""
|
||||||
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
|
if os.path.exists(cwd):
|
||||||
|
RunCommand(['./cros_mark_as_stable', '--srcroot=..',
|
||||||
|
'--tracking_branch="cros/master"', 'clean'],
|
||||||
|
cwd=cwd, error_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _CleanUpMountPoints(buildroot):
|
||||||
|
"""Cleans up any stale mount points from previous runs."""
|
||||||
|
mount_output = RunCommand(['mount'], redirect_stdout=True)
|
||||||
|
mount_pts_in_buildroot = RunCommand(['grep', buildroot], input=mount_output,
|
||||||
|
redirect_stdout=True, error_ok=True)
|
||||||
|
|
||||||
|
for mount_pt_str in mount_pts_in_buildroot.splitlines():
|
||||||
|
mount_pt = mount_pt_str.rpartition(' type ')[0].partition(' on ')[2]
|
||||||
|
RunCommand(['sudo', 'umount', '-l', mount_pt], error_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _WipeOldOutput(buildroot):
|
||||||
|
"""Wipes out build output directories."""
|
||||||
|
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
||||||
|
|
||||||
|
|
||||||
# =========================== Main Commands ===================================
|
# =========================== Main Commands ===================================
|
||||||
|
|
||||||
|
|
||||||
|
def _PreFlightRinse(buildroot):
|
||||||
|
"""Cleans up any leftover state from previous runs."""
|
||||||
|
_GitCleanup(buildroot)
|
||||||
|
_CleanUpMountPoints(buildroot)
|
||||||
|
RunCommand(['sudo', 'killall', 'kvm'], error_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
||||||
"""Performs a full checkout and clobbers any previous checkouts."""
|
"""Performs a full checkout and clobbers any previous checkouts."""
|
||||||
RunCommand(['sudo', 'rm', '-rf', buildroot])
|
RunCommand(['sudo', 'rm', '-rf', buildroot])
|
||||||
@ -229,12 +262,6 @@ def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
|||||||
RepoSync(buildroot, rw_checkout, retries)
|
RepoSync(buildroot, rw_checkout, retries)
|
||||||
|
|
||||||
|
|
||||||
def _PreFlightRinse(buildroot):
|
|
||||||
"""Cleans up any leftover state from previous runs."""
|
|
||||||
RunCommand(['sudo', 'killall', 'kvm'], error_ok=True)
|
|
||||||
_UprevCleanup(buildroot, error_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
def _IncrementalCheckout(buildroot, rw_checkout=True,
|
def _IncrementalCheckout(buildroot, rw_checkout=True,
|
||||||
retries=_DEFAULT_RETRIES):
|
retries=_DEFAULT_RETRIES):
|
||||||
"""Performs a checkout without clobbering previous checkout."""
|
"""Performs a checkout without clobbering previous checkout."""
|
||||||
@ -260,10 +287,6 @@ def _Build(buildroot):
|
|||||||
RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
|
RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
|
||||||
|
|
||||||
|
|
||||||
def _WipeOldOutput(buildroot):
|
|
||||||
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
|
|
||||||
|
|
||||||
|
|
||||||
def _EnableLocalAccount(buildroot):
|
def _EnableLocalAccount(buildroot):
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
# Set local account for test images.
|
# Set local account for test images.
|
||||||
@ -338,14 +361,6 @@ def _UprevPackages(buildroot, revisionfile, board):
|
|||||||
_UprevAllPackages(buildroot)
|
_UprevAllPackages(buildroot)
|
||||||
|
|
||||||
|
|
||||||
def _UprevCleanup(buildroot, error_ok=False):
|
|
||||||
"""Clean up after a previous uprev attempt."""
|
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
|
||||||
RunCommand(['./cros_mark_as_stable', '--srcroot=..',
|
|
||||||
'--tracking_branch="cros/master"', 'clean'],
|
|
||||||
cwd=cwd, error_ok=error_ok)
|
|
||||||
|
|
||||||
|
|
||||||
def _UprevPush(buildroot):
|
def _UprevPush(buildroot):
|
||||||
"""Pushes uprev changes to the main line."""
|
"""Pushes uprev changes to the main line."""
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
@ -398,10 +413,6 @@ def main():
|
|||||||
buildroot = options.buildroot
|
buildroot = options.buildroot
|
||||||
revisionfile = options.revisionfile
|
revisionfile = options.revisionfile
|
||||||
|
|
||||||
# Passed option to clobber.
|
|
||||||
if options.clobber:
|
|
||||||
RunCommand(['sudo', 'rm', '-rf', buildroot])
|
|
||||||
|
|
||||||
if len(args) >= 1:
|
if len(args) >= 1:
|
||||||
buildconfig = _GetConfig(args[-1])
|
buildconfig = _GetConfig(args[-1])
|
||||||
else:
|
else:
|
||||||
@ -410,10 +421,10 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir(buildroot):
|
_PreFlightRinse(buildroot)
|
||||||
|
if options.clobber or not os.path.isdir(buildroot):
|
||||||
_FullCheckout(buildroot)
|
_FullCheckout(buildroot)
|
||||||
else:
|
else:
|
||||||
_PreFlightRinse(buildroot)
|
|
||||||
_IncrementalCheckout(buildroot)
|
_IncrementalCheckout(buildroot)
|
||||||
|
|
||||||
chroot_path = os.path.join(buildroot, 'chroot')
|
chroot_path = os.path.join(buildroot, 'chroot')
|
||||||
@ -446,8 +457,6 @@ def main():
|
|||||||
if cbuildbot_comm.HaveSlavesCompleted(config):
|
if cbuildbot_comm.HaveSlavesCompleted(config):
|
||||||
_UprevPush(buildroot)
|
_UprevPush(buildroot)
|
||||||
else:
|
else:
|
||||||
# At least one of the slaves failed or we timed out.
|
|
||||||
_UprevCleanup(buildroot)
|
|
||||||
Die('CBUILDBOT - One of the slaves has failed!!!')
|
Die('CBUILDBOT - One of the slaves has failed!!!')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -455,7 +464,6 @@ def main():
|
|||||||
if buildconfig['important']:
|
if buildconfig['important']:
|
||||||
cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE)
|
cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE)
|
||||||
|
|
||||||
_UprevCleanup(buildroot)
|
|
||||||
except:
|
except:
|
||||||
# Send failure to master bot.
|
# Send failure to master bot.
|
||||||
if not buildconfig['master'] and buildconfig['important']:
|
if not buildconfig['master'] and buildconfig['important']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user