ci: Constrain parallel build jobs
authorJonathan Lebon <jonathan@jlebon.com>
Thu, 16 Jul 2020 15:42:57 +0000 (11:42 -0400)
committerJonathan Lebon <jonathan@jlebon.com>
Thu, 16 Jul 2020 19:44:34 +0000 (15:44 -0400)
The default `_NPROCESSORS_ONLN` heuristic we have isn't cgroups aware.
So it thinks it has e.g. 40 CPUs when running in a k8s pod. This can
then blow through our allocated resource limits.

Declare some modest amount of RAM and CPU resources and override `make`
parallelism.

This matches what rpm-ostree now does in
https://github.com/coreos/rpm-ostree/pull/2155.

.cci.jenkinsfile
ci/libbuild.sh

index 4315a1d05e393387cc4efce9098fc6527c4a0214..2a4c7288cdc74c1f89934a054011cad5cd03c0e9 100644 (file)
@@ -2,7 +2,8 @@
 
 stage("Build") {
 parallel normal: {
-  cosaPod(buildroot: true, runAsUser: 0) {
+  def n = 5
+  cosaPod(buildroot: true, runAsUser: 0, memory: "2Gi", cpu: "${n}") {
       checkout scm
       stage("Core build") {
         shwrap("""
@@ -10,7 +11,7 @@ parallel normal: {
           git fetch origin --tags
           git submodule update --init
 
-          env SKIP_INSTALLDEPS=1 ./ci/build.sh
+          env MAKE_JOBS=${n} SKIP_INSTALLDEPS=1 ./ci/build.sh
         """)
       }
       stage("Unit tests") {
@@ -84,18 +85,19 @@ parallel fcos: {
   }
 },
 buildopts: {
-  cosaPod(buildroot: true, runAsUser: 0) {
+  def n = 5
+  cosaPod(buildroot: true, runAsUser: 0, memory: "2Gi", cpu: "${n}") {
       checkout scm
       shwrap("""
         git submodule update --init
 
         git worktree add build-rust && cd build-rust
-        env CONFIGOPTS="--enable-rust" SKIP_INSTALLDEPS=1 ./ci/build.sh
+        env MAKE_JOBS=${n} CONFIGOPTS="--enable-rust" SKIP_INSTALLDEPS=1 ./ci/build.sh
         make check TESTS=tests/test-rollsum
         cd .. && rm -rf build-rust
 
         git worktree add build-libsoup && cd build-libsoup
-        env CONFIGOPTS="--without-curl --without-openssl --with-soup" SKIP_INSTALLDEPS=1 ./ci/build.sh
+        env MAKE_JOBS=${n} CONFIGOPTS="--without-curl --without-openssl --with-soup" SKIP_INSTALLDEPS=1 ./ci/build.sh
         make check
         cd .. && rm -rf build-libsoup
       """)
index a8ade0d7ad39f47ca8403497f964d58fdabb4db4..dece8d09543fc9d1b5b9e6d505d0d5e39dead15f 100644 (file)
@@ -10,7 +10,7 @@ pkg_upgrade() {
 }
 
 make() {
-    /usr/bin/make -j $(getconf _NPROCESSORS_ONLN) "$@"
+    /usr/bin/make -j ${MAKE_JOBS:-$(getconf _NPROCESSORS_ONLN)} "$@"
 }
 
 build() {