#50959 Issue 49731 - set and use db_home_directory by default
Closed 3 years ago by spichugi. Opened 4 years ago by mreynolds.
mreynolds/389-ds-base issue49731  into  master

@@ -58,6 +58,7 @@ 

  audit_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/audit

  error_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/errors

  db_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/db

+ db_home_dir = /dev/shm/dirsrv/slapd-{instance_name}

Just a dummy question regarding containers. Aren't they using the same /dev/shm ?
A risk for several containers running slapd-standalone1 to step on each other ?

  backup_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/bak

  ldif_dir = @localstatedir@/lib/dirsrv/slapd-{instance_name}/ldif

  

@@ -905,6 +905,7 @@ 

  cn: config

  nsslapd-mode: 600

  nsslapd-directory: %db_dir%

+ nsslapd-db-home-directory: %db_home_dir%

  nsslapd-subtree-rename-switch: on

  

  dn: cn=default indexes, cn=config,cn=ldbm database,cn=plugins,cn=config

file modified
+2
@@ -430,6 +430,7 @@ 

  mkdir -p $RPM_BUILD_ROOT/var/log/%{pkgname}

  mkdir -p $RPM_BUILD_ROOT/var/lib/%{pkgname}

  mkdir -p $RPM_BUILD_ROOT/var/lock/%{pkgname}

+ mkdir -p $RPM_BUILD_ROOT/dev/shm/%{pkgname}

  

  # for systemd

  mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/systemd/system/%{groupname}.wants
@@ -635,6 +636,7 @@ 

  %{_prefix}/lib/sysctl.d/*

  %dir %{_localstatedir}/lib/%{pkgname}

  %dir %{_localstatedir}/log/%{pkgname}

+ %dir /dev/shm/%{pkgname}

  %ghost %dir %{_localstatedir}/lock/%{pkgname}

  %exclude %{_sbindir}/ldap-agent*

  %exclude %{_mandir}/man1/ldap-agent.1.gz

@@ -44,6 +44,7 @@ 

      remove_paths['cert_dir'] = dirsrv.ds_paths.cert_dir

      remove_paths['config_dir'] = dirsrv.ds_paths.config_dir

      remove_paths['db_dir'] = dirsrv.ds_paths.db_dir

+     remove_paths['db_home_dir'] = dirsrv.ds_paths.db_home_dir

      remove_paths['db_dir_parent'] = dirsrv.ds_paths.db_dir + "/../"

      ### WARNING: The changelogdb isn't removed. we assume it's in:

      # db_dir ../changelogdb. So remove that too!

@@ -281,6 +281,7 @@ 

                   'inst_dir': ds_paths.inst_dir,

                   'backup_dir': ds_paths.backup_dir,

                   'db_dir': ds_paths.db_dir,

+                  'db_home_dir': ds_paths.db_home_dir,

                   'ldif_dir': ds_paths.ldif_dir,

                   'lock_dir': ds_paths.lock_dir,

                   'log_dir': ds_paths.log_dir,
@@ -740,11 +741,12 @@ 

                  ds_suffix=ds_suffix,

                  config_dir=slapd['config_dir'],

                  db_dir=slapd['db_dir'],

+                 db_home_dir=slapd['db_home_dir']

              ))

  

          # Create all the needed paths

          # we should only need to make bak_dir, cert_dir, config_dir, db_dir, ldif_dir, lock_dir, log_dir, run_dir?

-         for path in ('backup_dir', 'cert_dir', 'db_dir', 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):

+         for path in ('backup_dir', 'cert_dir', 'db_dir', 'db_home_dir', 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):

              self.log.debug("ACTION: creating %s", slapd[path])

              try:

                  os.umask(0o007)  # For parent dirs that get created -> sets 770 for perms
@@ -864,8 +866,9 @@ 

  

          # Do selinux fixups

          if general['selinux']:

-             selinux_paths = ('backup_dir', 'cert_dir', 'config_dir', 'db_dir', 'ldif_dir',

-                              'lock_dir', 'log_dir', 'run_dir', 'schema_dir', 'tmp_dir')

+             selinux_paths = ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',

+                              'db_home_dir', 'ldif_dir', 'lock_dir', 'log_dir',

+                              'run_dir', 'schema_dir', 'tmp_dir')

              for path in selinux_paths:

                  selinux_restorecon(slapd[path])

  

file modified
+3 -1
@@ -57,6 +57,7 @@ 

      'log_dir',

      'inst_dir',

      'db_dir',

+     'db_home_dir',

      'backup_dir',

      'ldif_dir',

      'initconfig_dir',
@@ -76,6 +77,7 @@ 

      'lock_dir' : ('cn=config','nsslapd-lockdir'),

      'inst_dir' : ('cn=config','nsslapd-instancedir'),

      'db_dir' : ('cn=config,cn=ldbm database,cn=plugins,cn=config', 'nsslapd-directory'),

+     'db_home_dir' : ('cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config', 'nsslapd-db-home-directory'),

      'backup_dir': ('cn=config','nsslapd-bakdir'),

      'ldif_dir': ('cn=config','nsslapd-ldifdir'),

      'error_log' : ('cn=config', 'nsslapd-errorlog'),
@@ -128,7 +130,7 @@ 

          for spath in search_paths:

              if os.path.isfile(spath):

                  return spath

-         raise IOError('defaults.inf not found in any wellknown location!')

+         raise IOError('defaults.inf not found in any well known location!')

  

      def _read_defaults(self):

          spath = self._get_defaults_loc(DEFAULTS_PATH)

Description:

New instances will automatically create and use db_home_dir /dev/shm/dirsrv/slapd-INSTANCE.

relates: https://pagure.io/389-ds-base/issue/49731

Just a dummy question regarding containers. Aren't they using the same /dev/shm ?
A risk for several containers running slapd-standalone1 to step on each other ?

Just a dummy question regarding containers. Aren't they using the same /dev/shm ?
A risk for several containers running slapd-standalone1 to step on each other ?

That's a good question. If there are multiple instances with the same name then that would definitely be a problem. I'd hate to have to globally disable this feature if it's "containerised". Is that how customers deploy containers? One system with multiple images? I ask because maybe we could document that caveat?

In containers they each get their own /dev/shm I think, I think they are seperated. So I think that shouldn't be arisk. Certainly we can test this and then roll back if it's a problem. :)

rebased onto b097eadfffda2be904ff9ca8cda1f6f38398d32c

4 years ago

The patch looks good to me. Ack

rebased onto 96c8abb

4 years ago

Pull-Request has been merged by mreynolds

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4012

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago