Bug 15205

Summary: Need to cleanup work directories for cancelled builds
Product: [Infrastructure] AutoBuilder Reporter: Richard Purdie <richard.purdie>
Component: autobuilderAssignee: Alexander Kanavin <alex.kanavin>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: alex.kanavin, infras.ab.watcher, Infras.watcher, mhalstead, pidge
Version: unspecified   
Target Milestone: 4.3 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
proposed patch (untested) none

Description Richard Purdie 2023-09-04 10:48:33 UTC
When builds are cancelled, large work directories are left behind and with the limited storage on our SSDs, this is problematic.

we either need:

a) to find a way to query buildbot, "is this build directory actively being used?"
and then remove any build/build/ directory that isn't active 

-or-

b) find a way to have a cancelled build cleanup hook that runs when a build is cancelled
Comment 1 Alexander Kanavin 2023-09-08 17:24:51 UTC
This is where interrupting a build step is implemented:

http://docs.buildbot.net/current/developer/cls-buildsteps.html#buildbot.process.buildstep.BuildStep.interrupt

Next is to check how it's implemented, and whether it is extensible or sub-classable etc.
Comment 2 Alexander Kanavin 2023-09-11 11:59:58 UTC
--- a/builders.py
+++ b/builders.py
@@ -128,11 +128,12 @@ def create_builder_factory():
 
     f.addStep(RunConfigCheckSteps(posttrigger=False))
 
-    # If the build was successful, clean up the build directory
+    # If the build was successful or cancelled, clean up the build directory
     f.addStep(steps.ShellCommand(
         command=[clob, util.Interpolate("%(prop:builddir)s/")],
-        doStepIf=lambda step: step.build.results == SUCCESS,
+        doStepIf=lambda step: step.build.results in (SUCCESS, CANCELLED),
         haltOnFailure=False,
+        alwaysRun=True,
         name="Clobber build dir"))
 
     return f


This needs to be tested, as I'm not completely sure that alwaysRun will run the step also when the previous one was interrupted by the stop button.
Comment 3 Alexander Kanavin 2023-09-11 12:01:00 UTC
Created attachment 4975 [details]
proposed patch (untested)