phase1: add config option for shared workdir
authorThibaut VARÈNE <hacks@slashdirt.org>
Fri, 22 Jun 2018 13:25:47 +0000 (15:25 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 26 Jun 2018 20:09:10 +0000 (22:09 +0200)
This patch adds a per-slave configuration option:
    shared_wd = <boolean>

This option defaults to False if unset, and should be set to True for
slaves that share a single workdir among all workers.

When it is True, expires.sh and cleanup.sh are disabled as the workdir
housekeeping is entirely handled by the Git() step and the value of the
'do_cleanup' configuration option.

expires.sh and cleanup.sh are unnecessary and potentially detrimental in
this context.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
phase1/master.cfg

index 09fed6a47087b140f298e5f8747e3a5a98b86336..62675f153bf5f1ff17f97e2bac3ae2cedd1ada9f 100644 (file)
@@ -53,7 +53,7 @@ NetLocks = dict()
 for section in ini.sections():
        if section.startswith("slave "):
                if ini.has_option(section, "name") and ini.has_option(section, "password"):
-                       sl_props = { 'dl_lock':None, 'ul_lock':None, 'do_cleanup':False, 'max_builds':1 }
+                       sl_props = { 'dl_lock':None, 'ul_lock':None, 'do_cleanup':False, 'max_builds':1, 'shared_wd':False }
                        name = ini.get(section, "name")
                        password = ini.get(section, "password")
                        max_builds = 1
@@ -72,6 +72,11 @@ for section in ini.sections():
                                sl_props['ul_lock'] = lockname
                                if lockname not in NetLocks:
                                        NetLocks[lockname] = locks.MasterLock(lockname)
+                       if ini.has_option(section, "shared_wd"):
+                               shared_wd = ini.getboolean(section, "shared_wd")
+                               sl_props['shared_wd'] = shared_wd
+                               if shared_wd and (max_builds != 1):
+                                       raise ValueError('max_builds must be 1 with shared workdir!')
                        c['slaves'].append(BuildSlave(name, password, max_builds = max_builds, properties = sl_props))
 
 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
@@ -227,6 +232,9 @@ def IsMakeCleanRequested(pattern):
        return CheckCleanProperty
 
 def IsCleanupRequested(step):
+       shared_wd = step.getProperty("shared_wd")
+       if shared_wd:
+               return False
        do_cleanup = step.getProperty("do_cleanup")
        if do_cleanup:
                return True
@@ -234,7 +242,11 @@ def IsCleanupRequested(step):
                return False
 
 def IsExpireRequested(step):
-       return not IsCleanupRequested(step)
+       shared_wd = step.getProperty("shared_wd")
+       if shared_wd:
+               return False
+       else:
+               return not IsCleanupRequested(step)
 
 def IsGitFreshRequested(step):
        do_cleanup = step.getProperty("do_cleanup")