phase2: implement work dir sharing
authorJo-Philipp Wich <jo@mein.io>
Thu, 18 Jul 2019 12:42:14 +0000 (14:42 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 18 Jul 2019 12:45:34 +0000 (14:45 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
phase1/master.cfg
phase2/master.cfg

index d9ca8d8e8f35731e4459a71e071ce30143ff331d..a91864aaabf5bcad87dd20f2769e4b597797f216 100644 (file)
@@ -471,7 +471,7 @@ for target in targets:
        factory.addStep(ShellCommand(
                name = "sharedwd",
                description = "Setting up shared work directory",
-               command = 'test -L "$PWD" || (mkdir -p "../shared-workdir" && rm -rf "$PWD" && ln -s shared-workdir "$PWD")',
+               command = 'test -L "$PWD" || (mkdir -p ../shared-workdir && rm -rf "$PWD" && ln -s shared-workdir "$PWD")',
                workdir = ".",
                haltOnFailure = True,
                doStepIf = IsSharedWorkdir))
index ed09c8b1b863e3b25342311239d99f68bd093743..6b8214b8de83651114ed53fc867c98eb539fa060 100644 (file)
@@ -64,10 +64,21 @@ for section in ini.sections():
                   ini.has_option(section, "phase") and ini.getint(section, "phase") == 2:
                        name = ini.get(section, "name")
                        password = ini.get(section, "password")
+                       sl_props = { 'shared_wd': False }
                        max_builds[name] = 1
+
                        if ini.has_option(section, "builds"):
                                max_builds[name] = ini.getint(section, "builds")
-                       c['slaves'].append(BuildSlave(name, password, max_builds = max_builds[name]))
+
+                       if max_builds[name] == 1:
+                               sl_props['shared_wd'] = True
+
+                       if ini.has_option(section, "shared_wd"):
+                               sl_props['shared_wd'] = ini.getboolean(section, "shared_wd")
+                               if sl_props['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[name], properties = sl_props))
 
 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
 # This must match the value configured into the buildslaves (with their
@@ -244,6 +255,9 @@ def UsignSec2Pub(seckey, comment="untrusted comment: secret key"):
        return "{}\n{}".format(re.sub(r"\bsecret key$", "public key", comment),
                base64.b64encode(seckey[0:2] + seckey[32:40] + seckey[72:]))
 
+def IsSharedWorkdir(step):
+       return bool(step.getProperty("shared_wd"))
+
 
 c['builders'] = []
 
@@ -259,6 +273,15 @@ for arch in arches:
 
        factory = BuildFactory()
 
+       # setup shared work directory if required
+       factory.addStep(ShellCommand(
+               name = "sharedwd",
+               description = "Setting up shared work directory",
+               command = 'test -L "$PWD" || (mkdir -p ../shared-workdir && rm -rf "$PWD" && ln -s shared-workdir "$PWD")',
+               workdir = ".",
+               haltOnFailure = True,
+               doStepIf = IsSharedWorkdir))
+
        # find number of cores
        factory.addStep(SetProperty(
                name = "nproc",