#51007 Issue 49731 - Fix additional issues with setting db home directory by default
Closed 3 years ago by spichugi. Opened 3 years ago by mreynolds.
mreynolds/389-ds-base issue49731  into  master

@@ -225,9 +225,9 @@ 

      my $mode = getMode($inf, 7);

      my @errs;

  

-     my @dsdirs = qw(config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_dir ldif_dir bak_dir);

+     my @dsdirs = qw(config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_home_dir db_dir ldif_dir bak_dir);

      if ($inf->{slapd}->{InstScriptsEnabled} eq "true") {

-         @dsdirs = qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_dir ldif_dir bak_dir);

+         @dsdirs = qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_home_dir db_dir ldif_dir bak_dir);

      }

  

      # These paths are owned by the SuiteSpotGroup
@@ -313,7 +313,8 @@ 

              "RUN-DIR" => $inf->{slapd}->{run_dir},

              "PRODUCT-NAME" => "slapd",

              "SERVERBIN-DIR" => $inf->{slapd}->{sbindir},

-             "DB-DIR" => $inf->{slapd}->{db_dir}

+             "DB-DIR" => $inf->{slapd}->{db_dir},

+             "DB-HOME-DIR" => $inf->{slapd}->{db_home_dir}

          );

  

  
@@ -952,6 +953,10 @@ 

          }

      }

  

+     if (!defined($inf->{slapd}->{db_home_dir})) {

+         $inf->{slapd}->{db_home_dir} = "/dev/shm/@PACKAGE_NAME@/slapd-$servid";

+     }

+ 

      if (!defined($inf->{slapd}->{bak_dir})) {

          if ("@with_fhs_opt@") {

              $inf->{slapd}->{bak_dir} = "$localstatedir/@PACKAGE_NAME@/slapd-$servid/bak";
@@ -1008,9 +1013,9 @@ 

              system("restorecon -R $localstatedir/lib/@PACKAGE_NAME@");

          }

  

-         my @inst_dirs = qw(config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_dir ldif_dir bak_dir);

+         my @inst_dirs = qw(config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_home_dir db_dir ldif_dir bak_dir);

          if ($inf->{slapd}->{InstScriptsEnabled} eq "true") {

-             @inst_dirs = qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_dir ldif_dir bak_dir);

+             @inst_dirs = qw(inst_dir config_dir schema_dir log_dir lock_dir run_dir tmp_dir cert_dir db_home_dir db_dir ldif_dir bak_dir);

          }

          # run restorecon on all instance directories we created

          for my $kw (@inst_dirs) {

@@ -493,6 +493,10 @@ 

          $inf->{slapd}->{db_dir} = $entry->getValue('nsslapd-directory');

      }

  

+     if (!$inf->{slapd}->{db_home_dir}) {

+         $inf->{slapd}->{db_home_dir} = $entry->getValue('nsslapd-db-home-directory');

+     }

+ 

      $conn->close(); # don't need this anymore

  

      # set defaults for things we don't know how to find, after setting the values

@@ -36,5 +36,6 @@ 

  log_dir =       log_dir

  config_dir =    config_dir

  db_dir =        db_dir

+ db_home_dir =   db_home_dir

  run_dir =       run_dir

  instance_name = ServerIdentifier

@@ -33,4 +33,5 @@ 

  log_dir =       log_dir

  config_dir =    config_dir

  db_dir =        db_dir

+ db_home_dir =   db_home_dir

  run_dir =       run_dir

@@ -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

@@ -53,8 +53,8 @@ 

      /* Open the file */

      if ((prfd = PR_Open(filename, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,

                          SLAPD_DEFAULT_FILE_MODE)) == NULL) {

-         slapi_log_err(SLAPI_LOG_ERR, "bdb_version_write - "

-                                      "Could not open file \"%s\" for writing " SLAPI_COMPONENT_NAME_NSPR " %d (%s)\n",

+         slapi_log_err(SLAPI_LOG_ERR, "bdb_version_write",

+                       "Could not open file \"%s\" for writing " SLAPI_COMPONENT_NAME_NSPR " %d (%s)\n",

                        filename, PR_GetError(), slapd_pr_strerror(PR_GetError()));

          rc = -1;

      } else {

@@ -720,7 +720,11 @@ 

                  dse += line.replace('%', '{', 1).replace('%', '}', 1)

  

          with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse:

-             file_dse.write(dse.format(

+             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'],

                  tmp_dir=slapd['tmp_dir'],
@@ -741,8 +745,9 @@ 

                  ds_suffix=ds_suffix,

                  config_dir=slapd['config_dir'],

                  db_dir=slapd['db_dir'],

-                 db_home_dir=slapd['db_home_dir']

-             ))

+                 db_home_dir=db_home_dir

+             )

+             file_dse.write(dse_fmt)

  

          # 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?

Description:

The db home dir does need to be set in the template-dse.ldif file, but this required additional changes to perl modules that setup-ds.pl uses. There are also issues with containers where /dev/shm could be undersized for the database, so for container installs we will not set the db-home-dir to tmpfs.

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

rebased onto 52e2894

3 years ago

Pull-Request has been merged by mreynolds

3 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/4060

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