From bf25285fe8ccdb50499aeb6b6955be86bddcbbaf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9ctor=20Or=C3=B3n=20Mart=C3=ADnez?=
 <hector.oron@collabora.com>
Date: Fri, 22 Mar 2019 13:01:45 +0100
Subject: [PATCH] worker: override DefaultTasksMax
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The following error
```
[   67s] Unpacking gcc-7 (7.3.0-16ubuntu3) ...
[   67s] dpkg-deb: unrecoverable fatal error, aborting:
[   67s]  fork failed: Resource temporarily unavailable
[   67s] dpkg: error processing archive /var/cache/apt/archives/gcc-7_7.3.0-16ubuntu3_i386.deb (--unpack):
[   67s]  dpkg-deb --fsys-tarfile subprocess returned error exit status 2
[   67s] dpkg: unrecoverable fatal error, aborting:
[   67s]  fork failed: Resource temporarily unavailable
[   67s] /usr/sbin/debootstrap: 996: /usr/sbin/debootstrap: Cannot fork
[...]
```

happens since all builds happen in the same cgroup which is limited to 4915,
while builds have NPROC rlimits (just over 64000). If it reaches a total of
4915 tasks (processes and threads) calls like `fork()`, `clone()`,
`pthread_create()` will fail.

This is a short term fix proposed by Simon McVittie, while the long term
solution should place each `bs_worker` instance in its own systemd-managed
cgroup. The default task limit of 4915 might then be adequated.

Signed-off-by: Héctor Orón Martínez <hector.oron@collabora.com>
---
 debian/obs-worker.install                     | 2 ++
 debian/systemd/obsworker.service.d/tasks.conf | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100644 debian/obs-worker.install
 create mode 100644 debian/systemd/obsworker.service.d/tasks.conf

diff --git a/debian/obs-worker.install b/debian/obs-worker.install
new file mode 100644
index 0000000000..352905553b
--- /dev/null
+++ b/debian/obs-worker.install
@@ -0,0 +1,2 @@
+# systemd override
+debian/systemd/obsworker.service.d/tasks.conf	/lib/systemd/obsworker.service.d/
diff --git a/debian/systemd/obsworker.service.d/tasks.conf b/debian/systemd/obsworker.service.d/tasks.conf
new file mode 100644
index 0000000000..2f1dd69bbc
--- /dev/null
+++ b/debian/systemd/obsworker.service.d/tasks.conf
@@ -0,0 +1,2 @@
+[Service]
+TasksMax=64000
-- 
GitLab