From d7810ffc4af6acb30b12354db0eeaaf4f9c9749e Mon Sep 17 00:00:00 2001 From: William Brown Date: Apr 14 2020 05:44:20 +0000 Subject: Ticket 51008 - dbhome in containers Bug Description: When starting 389 in containers, the shm may be too small. Mark fixed this in #51007, but it removed the ability to have the dbhome in a tmpfs/shm. Fix Description: Move the request for dbhome/container logic into the dscontainer entry point instead to keep the setup.py simpler, and make the dbhome in /data/run/dbhome allowing people to use an shm for dbhome with '--tmpfs /data/run/dbhome:rw' to a docker run or create command. https://pagure.io/389-ds-base/issue/51008 Author: William Brown Review by: ??? --- diff --git a/src/lib389/cli/dscontainer b/src/lib389/cli/dscontainer index 7117637..4977fe1 100755 --- a/src/lib389/cli/dscontainer +++ b/src/lib389/cli/dscontainer @@ -181,6 +181,7 @@ def begin_magic(): '/data/ldif', '/data/run', '/data/run/lock', + '/data/run/dbhome', '/data/logs' ]: if not os.path.exists(d): @@ -222,6 +223,14 @@ def begin_magic(): s2b.set('local_state_dir', '/data') s2b.set('inst_dir', '/data') s2b.set('db_dir', '/data/db') + # 51008, ds changed dbhome for bdb to /dev/shm, however in docker this + # defaults to 64M and DS requires at least 130M. It may not be possible to + # Ask people to change this in their deployments, and in the interest of + # simplicity, we just put this into a /data/run directory instead to make + # containers as painless as possible. If people want it to be a ram disk + # they can easily use something like: + # docker run --tmpfs /data/run/dbhome:rw + s2b.set('db_home_dir', '/data/run/dbhome') # Why is this bak? Some dsctl commands use INST_DIR/bak, not "backup_dir" # due to some legacy handling of paths in lib389's population of instances. s2b.set('backup_dir', '/data/bak') diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index 60eb6c7..bc514c7 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -720,10 +720,6 @@ class SetupDs(object): dse += line.replace('%', '{', 1).replace('%', '}', 1) with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse: - db_home_dir = slapd['db_home_dir'] - if self.containerised: - # don't set db_home_dir to tmpfs in containers - db_home_dir = slapd['db_dir'] dse_fmt = dse.format( schema_dir=slapd['schema_dir'], lock_dir=slapd['lock_dir'], @@ -745,7 +741,7 @@ class SetupDs(object): ds_suffix=ds_suffix, config_dir=slapd['config_dir'], db_dir=slapd['db_dir'], - db_home_dir=db_home_dir + db_home_dir=slapd['db_home_dir'] ) file_dse.write(dse_fmt)