<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15205</bug_id>
          
          <creation_ts>2023-09-04 10:48:33 +0000</creation_ts>
          <short_desc>Need to cleanup work directories for cancelled builds</short_desc>
          <delta_ts>2023-09-13 10:27:15 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>5</classification_id>
          <classification>Infrastructure</classification>
          <product>AutoBuilder</product>
          <component>autobuilder</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.3 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Alexander Kanavin">alex.kanavin</assigned_to>
          <cc>alex.kanavin</cc>
    
    <cc>infras.ab.watcher</cc>
    
    <cc>Infras.watcher</cc>
    
    <cc>mhalstead</cc>
    
    <cc>pidge</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96340</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-09-04 10:48:33 +0000</bug_when>
    <thetext>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, &quot;is this build directory actively being used?&quot;
and then remove any build/build/ directory that isn&apos;t active 

-or-

b) find a way to have a cancelled build cleanup hook that runs when a build is cancelled</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96390</commentid>
    <comment_count>1</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2023-09-08 17:24:51 +0000</bug_when>
    <thetext>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&apos;s implemented, and whether it is extensible or sub-classable etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96395</commentid>
    <comment_count>2</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2023-09-11 11:59:58 +0000</bug_when>
    <thetext>--- 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(&quot;%(prop:builddir)s/&quot;)],
-        doStepIf=lambda step: step.build.results == SUCCESS,
+        doStepIf=lambda step: step.build.results in (SUCCESS, CANCELLED),
         haltOnFailure=False,
+        alwaysRun=True,
         name=&quot;Clobber build dir&quot;))
 
     return f


This needs to be tested, as I&apos;m not completely sure that alwaysRun will run the step also when the previous one was interrupted by the stop button.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96396</commentid>
    <comment_count>3</comment_count>
      <attachid>4975</attachid>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2023-09-11 12:01:00 +0000</bug_when>
    <thetext>Created attachment 4975
proposed patch (untested)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96403</commentid>
    <comment_count>4</comment_count>
    <who name="Alexander Kanavin">alex.kanavin</who>
    <bug_when>2023-09-13 10:27:15 +0000</bug_when>
    <thetext>The patch seems to be working:
https://autobuilder.yoctoproject.org/typhoon/#/builders/37/builds/7793

https://git.yoctoproject.org/yocto-autobuilder2/commit/?id=adcf9d6143451c6700aa1ca3763155b3bb986e47</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4975</attachid>
            <date>2023-09-11 12:01:00 +0000</date>
            <delta_ts>2023-09-11 12:01:00 +0000</delta_ts>
            <desc>proposed patch (untested)</desc>
            <filename>0001-builders.py-clobber-build-dir-also-when-the-build-wa.patch</filename>
            <type>text/plain</type>
            <size>1221</size>
            <attacher name="Alexander Kanavin">alex.kanavin</attacher>
            
              <data encoding="base64">RnJvbSA5ZTUxNzU4ZTQyYjRmOGIxZWNjZmI4MDkzMmE3NWQ1ODhkNWZmNGE5IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBBbGV4YW5kZXIgS2FuYXZpbiA8YWxleC5rYW5hdmluQGdtYWls
LmNvbT4KRGF0ZTogTW9uLCAxMSBTZXAgMjAyMyAxMzo1NDoyMCArMDIwMApTdWJqZWN0OiBbeW9j
dG8tYXV0b2J1aWxkZXIyXVtQQVRDSF0gYnVpbGRlcnMucHk6IGNsb2JiZXIgYnVpbGQgZGlyIGFs
c28gd2hlbgogdGhlIGJ1aWxkIHdhcyBjYW5jZWxsZWQKClRoaXMgZW5hYmxlcyBmYXN0ZXIgY2xl
YW51cCBvZiBjYW5jZWxsZWQgYnVpbGRzLCByZWR1Y2luZyBjaGFuY2UKb2YgZGlzayBzcGFjZSBy
dW5uaW5nIG91dC4KCltZT0NUTyAjMTUyMDVdCgpTaWduZWQtb2ZmLWJ5OiBBbGV4YW5kZXIgS2Fu
YXZpbiA8YWxleC5rYW5hdmluQGdtYWlsLmNvbT4KLS0tCiBidWlsZGVycy5weSB8IDUgKysrLS0K
IDEgZmlsZSBjaGFuZ2VkLCAzIGluc2VydGlvbnMoKyksIDIgZGVsZXRpb25zKC0pCgpkaWZmIC0t
Z2l0IGEvYnVpbGRlcnMucHkg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