Skip to contentSkip to conversation

autobuild: new config options; conf file, startup script (branch yem/limits)

PATCH Superseded Yann E. MORIN 1 participant 5 messages Nov 25, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover autobuild: new config options; conf file, startup script (branch yem/limits)

Hello All!

This series, against the autobuilder tree, adds two new configuration options, a sample runtime config file, and a SysV init startup script.

The two new rutime options are:
--nice N specify the niceness of the 'make' command
--pid-file file where to save the main process PID

The niceness allows limitting the impact of the autobuilder on the rest of the job, when on a shared machine. A better solution would be to implement a container with cgroups, but a systemd unit file would be so much convenient! ;-)

The PID file allows to simplify the startup script, and really ensure that we get the autobuild process' PID.

A SysV init startup script, as well as a sample defaults config file are provided, to ease running the autobuild script as a daemon.

A sample runtime configuration file is provided as well.

Note that nothing in there is really bullet-proof...

Regards,
Yann E. MORIN.

The following changes since commit 611b515aa40c635d1af24883a9eab9e1e363a33c:

Add mips32r6 and mips64r6 toolchains (2015-11-22 15:31:07 +0100)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot-test yem/limits

for you to fetch changes up to 9243b48a5bc32c35039519eabf4b6946f36f3260:

etc: add SysV-init startup script and sample config file (2015-11-25 23:58:32 +0100)

----------------------------------------------------------------
Yann E. MORIN (4):
autobuild: add config option to set niceness
autobuild: store PID to PID file
conf: add a sample run-time configuration file
etc: add SysV-init startup script and sample config file

 conf/buildroot-autobuild.sample |   5 ++
 etc/default/buildroot-autobuild |  23 +++++++
 etc/init.d/buildroot-autobuild  | 148 ++++++++++++++++++++++++++++++++++++++++
 scripts/autobuild-run           |  17 ++++-
 4 files changed, 192 insertions(+), 1 deletion(-)
 create mode 100644 conf/buildroot-autobuild.sample
 create mode 100644 etc/default/buildroot-autobuild
 create mode 100755 etc/init.d/buildroot-autobuild
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 1/4 autobuild: add config option to set niceness

When the machine running the autobuilder is shared, it is important that the autobuilder instances do not hog all of the CPU.

Add an option to the configuration, so that the user can set the niceness to run the instances with. By default, the niceness is 0, which means the current niceness.

Properly doing so would require setting up a container with proper CPU cgroup, but it's a bit complicated.

---
 scripts/autobuild-run | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
scripts/autobuild-run +9 -1
index 76b7201..db60f5c 100755
@@ -64,6 +64,7 @@ defaults = {
     '--njobs': '1',
     '--submitter': 'N/A',
     '--make-opts': '',
+    '--nice': 0,
 }
 
 doc = """autobuild-run - run Buildroot autobuilder
@@ -77,6 +78,8 @@ Options:
                                  Defaults to %(--ninstances)s.
   -j, --njobs NJOBS              number of parallel jobs
                                  Defaults to %(--njobs)s.
+  --nice N                       Niceness, positive number
+                                 Defaults to %(--nice)s.
   -s, --submitter SUBMITTER      name/machine of submitter
                                  Defaults to %(--submitter)s.
   --http-login LOGIN             username to send results with
@@ -101,6 +104,7 @@ Format of the configuration file:
    [main]
    ninstances = <value>
    njobs = <value>
+   nice = <value>
    http-login = <value>
    http-password = <value>
    submitter = <value>
@@ -540,6 +544,7 @@ def do_build(**kwargs):
 
     idir = "instance-%d" % kwargs['instance']
     log = kwargs['log']
+    nice = kwargs['nice']
 
     # We need the absolute path to use with O=, because the relative
     # path to the output directory here is not relative to the
@@ -551,7 +556,9 @@ def do_build(**kwargs):
     f = open(os.path.join(outputdir, "logfile"), "w+")
     log_write(log, "INFO: build started")
 
-    cmd = ["timeout", str(MAX_DURATION), "make", "O=%s" % outputdir,
+    cmd = ["timeout", str(MAX_DURATION),
+            "nice", "-n", nice,
+            "make", "O=%s" % outputdir,
             "-C", srcdir, "BR2_DL_DIR=%s" % dldir,
             "BR2_JLEVEL=%s" % kwargs['njobs']] \
           + kwargs['make_opts'].split()
@@ -851,6 +858,7 @@ def main():
                 http_password = args['--http-password'],
                 submitter = args['--submitter'],
                 make_opts = (args['--make-opts'] or ''),
+                nice = (args['--nice'] or 0),
                 upload = upload,
                 buildpid = buildpid
             ))
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/4 autobuild: store PID to PID file

In reply to Yann E. MORIN

Let the autobuild script store its own PID file, rather than retrieve it from the init script.

---
 scripts/autobuild-run | 7 +++++++
 1 file changed, 7 insertions(+)
scripts/autobuild-run +7 -0
index db60f5c..397c770 100755
@@ -65,6 +65,7 @@ defaults = {
     '--submitter': 'N/A',
     '--make-opts': '',
     '--nice': 0,
+    '--pid-file': '/tmp/buildroot-autobuild.pid',
 }
 
 doc = """autobuild-run - run Buildroot autobuilder
@@ -92,6 +93,8 @@ Options:
   --make-opts OPTSTRING          string of extra options to pass to Buildroot
                                  make, such as specific command wrappers
                                  Empty by default.
+  --pid-file PATH                path to a file where to store the PID
+                                 Defaults to %(--pid-file)s.
   -c, --config CONFIG            path to configuration file
                                  Not set by default.
 
@@ -807,6 +810,10 @@ def main():
     # load in defaults at lowest priority
     args = merge(args, defaults)
 
+    # Save our PID very early, so we can be stopped
+    with open(args['--pid-file'], "w+") as pidf:
+        pidf.write("%d" % os.getpid())
+
     # http_login/password could theoretically be allowed as empty, so check
     # explicitly on None.
     upload = (args['--http-login'] is not None) \
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/4 conf: add a sample run-time configuration file

In reply to Yann E. MORIN
---
 conf/buildroot-autobuild.sample | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 conf/buildroot-autobuild.sample
conf/buildroot-autobuild.sample new file +5 -0
new file mode 100644
index 0000000..dcb74b1
@@ -0,0 +1,5 @@
+[main]
+ninstances = 4
+njobs = 4
+nice = 20
+submitter = John Doe
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/4 etc: add SysV-init startup script and sample config file

In reply to Yann E. MORIN
---
 etc/default/buildroot-autobuild |  23 +++++++
 etc/init.d/buildroot-autobuild  | 148 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 171 insertions(+)
 create mode 100644 etc/default/buildroot-autobuild
 create mode 100755 etc/init.d/buildroot-autobuild
etc/default/buildroot-autobuild new file +23 -0
new file mode 100644
index 0000000..93b7365
@@ -0,0 +1,23 @@
+# The absolute path, outside the chroot, where the
+# buildroot-test tree is cloned, optional
+AUTOBUILD_DIR="/home/johndoe/buildroot-test"
+
+# The absolute path, outside the chroot, where to
+# share downloads (not yet implemented)
+#AUTOBUILD_DL_DIR="/home/johndoe/dl"
+
+# The absolute path to chroot into to rn the autobuild script
+AUTOBUILD_CHROOT="/var/chroot-autobuild"
+
+# User (in the chroot) that runs the autobuild script)
+AUTOBUILD_USER="buildroot"
+
+# The absolute path, in the chroot, that is the base of the
+# autobuild work dir. In there, you'll have:
+# - AUTOBUILD_CHROOT_DIR/buildroot-test
+#       the buildroot-test tree (bind-mounted from AUTOBUILD_DIR if set)
+# - AUTOBUILD_CHROOT_DIR/buildroot-autobuild.conf
+#       the run-time configuration of the autobuild script
+# - AUTOBUILD_CHROOT_DIR/run/
+#       the parent directory for all build instances
+AUTOBUILD_CHROOT_DIR="/home/buildroot/autobuild/"
etc/init.d/buildroot-autobuild new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.9.1