ci: Constrain parallel build jobs

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.
This commit is contained in:
Jonathan Lebon 2020-07-16 11:42:57 -04:00
parent 4752dd02cf
commit 92284f9b81
2 changed files with 8 additions and 6 deletions

View 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
""")

View 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() {