Bug 15205 - Need to cleanup work directories for cancelled builds
Summary: Need to cleanup work directories for cancelled builds
Status: RESOLVED FIXED
Alias: None
Product: AutoBuilder
Classification: Infrastructure
Component: autobuilder (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.3 M4
Assignee: Alexander Kanavin
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2023-09-04 10:48 UTC by Richard Purdie
Modified: 2023-09-13 10:27 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
proposed patch (untested) (1.19 KB, patch)
2023-09-11 12:01 UTC, Alexander Kanavin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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)