diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-25 10:39:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-26 14:37:27 +0100 |
commit | a07a971b40acd3eee12e203d2cfa3e49f56109f6 (patch) | |
tree | d299171eabed99ca98cf520c843e0d7fb15e0020 | |
parent | 032190aac31604d37740d8aecf6e74a5448de358 (diff) | |
download | bitbake-a07a971b40acd3eee12e203d2cfa3e49f56109f6.tar.gz |
bitbake-worker: Allow shutdown/database flush of pseudo server at task exit
We have a problem where pseudo server processes exist after bitbake exits
and hold the pseudo database in memory. In a docker container, the processes
will be killed as the container is destroyed with no warning and no opportunity
to write the data to disk. This leads to permissions/inode corruptions and
data loss.
Send a shutdown message to pseudo which in new versions of pseudo will flush
the database, thereby fixing some of the issues people using docker containers
see.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bin/bitbake-worker | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker index 6ead2da6d..115bc1d09 100755 --- a/bin/bitbake-worker +++ b/bin/bitbake-worker @@ -17,6 +17,8 @@ import signal import pickle import traceback import queue +import shlex +import subprocess from multiprocessing import Lock from threading import Thread @@ -146,6 +148,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha # a fork() or exec*() activates PSEUDO... envbackup = {} + fakeroot = False fakeenv = {} umask = None @@ -165,6 +168,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha # We can't use the fakeroot environment in a dry run as it possibly hasn't been built if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not dry_run: + fakeroot = True envvars = (workerdata["fakerootenv"][fn] or "").split() for key, value in (var.split('=') for var in envvars): envbackup[key] = os.environ.get(key) @@ -283,7 +287,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha try: if dry_run: return 0 - return bb.build.exec_task(fn, taskname, the_data, cfg.profile) + ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) + if fakeroot: + fakerootcmd = shlex.split(the_data.getVar("FAKEROOTCMD")) + subprocess.run(fakerootcmd + ['-S'], check=True, stdout=subprocess.PIPE) + return ret except: os._exit(1) if not profiling: |