Blame SOURCES/0047-Ticket-48243-replica-upgrade-failed-in-starting-dirs.patch

a2f18f
From d88650af2dc614519bdb138b162d3c6e3b5ae9c5 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Tue, 18 Aug 2015 13:43:55 -0700
a2f18f
Subject: [PATCH 47/47] Ticket #48243 - replica upgrade failed in starting
a2f18f
 dirsrv service due to upgrade scripts did not run
a2f18f
a2f18f
Description: In the upgrade process, there is a combination of requirements:
a2f18f
 . the server is running.
a2f18f
 . the server instance service is disabled.
a2f18f
 . upgrade scripts are expected to run against the instance.
a2f18f
 . the server is restarted once the upgrade is done.
a2f18f
 . the server instance service remains disabled.
a2f18f
To fulfill the requirements,
a2f18f
 . spec file is modified to enumerate slapd dir (except .remove) in the
a2f18f
   /etc/dirsrv for getting the server instance.
a2f18f
 . Start/Update perl scripts are modified not to create a symlink in
a2f18f
   /etc/systemd/system/dirsrv.target.wants for the upgrade case, which
a2f18f
   means the service remains disabled.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48243
a2f18f
a2f18f
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
a2f18f
a2f18f
(cherry picked from commit 29c09a5bcc7d54be1aa6880b4f2a423edd3dc463)
a2f18f
(cherry picked from commit 2c5e0d5692bcabe16a7e3b8e0d24eb3a88913155)
a2f18f
---
a2f18f
 ldap/admin/src/scripts/DSCreate.pm.in    |  7 ++++---
a2f18f
 ldap/admin/src/scripts/DSMigration.pm.in |  2 +-
a2f18f
 ldap/admin/src/scripts/DSUpdate.pm.in    |  2 +-
a2f18f
 rpm/389-ds-base.spec.in                  | 20 +++++++++++++-------
a2f18f
 4 files changed, 19 insertions(+), 12 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
index e4a4ed0..cdde339 100644
a2f18f
--- a/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
a2f18f
@@ -1098,6 +1098,7 @@ sub updateTmpfilesDotD {
a2f18f
 }
a2f18f
 
a2f18f
 sub updateSystemD {
a2f18f
+    my $noservicelink = shift;
a2f18f
     my $inf = shift;
a2f18f
     my $unitdir = "@systemdsystemunitdir@";
a2f18f
     my $confbasedir = "@systemdsystemconfdir@";
a2f18f
@@ -1129,7 +1130,7 @@ sub updateSystemD {
a2f18f
             next;
a2f18f
         } else {
a2f18f
             my $servicelink = "$confdir/$pkgname\@$inst.service";
a2f18f
-            if (! -l $servicelink) {
a2f18f
+            if (! -l $servicelink && ! $noservicelink) {
a2f18f
                 if (!symlink($servicefile, $servicelink)) {
a2f18f
                     debug(1, "error updating link $servicelink to $servicefile - $!\n");
a2f18f
                     push @errs, [ 'error_linking_file', $servicefile, $servicelink, $! ];
a2f18f
@@ -1216,7 +1217,7 @@ sub createDSInstance {
a2f18f
         return @errs;
a2f18f
     }
a2f18f
 
a2f18f
-    if (@errs = updateSystemD($inf)) {
a2f18f
+    if (@errs = updateSystemD(0, $inf)) {
a2f18f
         return @errs;
a2f18f
     }
a2f18f
 
a2f18f
@@ -1452,7 +1453,7 @@ sub removeDSInstance {
a2f18f
     }
a2f18f
 
a2f18f
     # update systemd files
a2f18f
-    push @errs, updateSystemD();
a2f18f
+    push @errs, updateSystemD(0);
a2f18f
     
a2f18f
     # if we got here, report success
a2f18f
     if (@errs) {
a2f18f
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in b/ldap/admin/src/scripts/DSMigration.pm.in
a2f18f
index e59e667..630ab43 100644
a2f18f
--- a/ldap/admin/src/scripts/DSMigration.pm.in
a2f18f
+++ b/ldap/admin/src/scripts/DSMigration.pm.in
a2f18f
@@ -1132,7 +1132,7 @@ sub migrateDS {
a2f18f
         }
a2f18f
 
a2f18f
 	# do the systemd stuff
a2f18f
-        @errs = DSCreate::updateSystemD($inf);
a2f18f
+        @errs = DSCreate::updateSystemD(0, $inf);
a2f18f
         if (@errs) {
a2f18f
             $mig->msg(@errs);
a2f18f
             goto cleanup;
a2f18f
diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in b/ldap/admin/src/scripts/DSUpdate.pm.in
a2f18f
index 1809ad9..be1e67c 100644
a2f18f
--- a/ldap/admin/src/scripts/DSUpdate.pm.in
a2f18f
+++ b/ldap/admin/src/scripts/DSUpdate.pm.in
a2f18f
@@ -408,7 +408,7 @@ sub updateDSInstance {
a2f18f
 
a2f18f
     push @errs, updateTmpfilesDotD($inf);
a2f18f
 
a2f18f
-    push @errs, updateSystemD($inf);
a2f18f
+    push @errs, updateSystemD(1, $inf);
a2f18f
 
a2f18f
     return @errs;
a2f18f
 }
a2f18f
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
a2f18f
index d0bbb7a..b7556e1 100644
a2f18f
--- a/rpm/389-ds-base.spec.in
a2f18f
+++ b/rpm/389-ds-base.spec.in
a2f18f
@@ -248,6 +248,7 @@ rm -rf $RPM_BUILD_ROOT
a2f18f
 
a2f18f
 %post
a2f18f
 output=/dev/null
a2f18f
+output2=/dev/null
a2f18f
 %systemd_post %{pkgname}-snmp.service
a2f18f
 # reload to pick up any changes to systemd files
a2f18f
 /bin/systemctl daemon-reload >$output 2>&1 || :
a2f18f
@@ -260,12 +261,17 @@ instances="" # instances that require a restart after upgrade
a2f18f
 ninst=0 # number of instances found in total
a2f18f
 if [ -n "$DEBUGPOSTTRANS" ] ; then
a2f18f
    output=$DEBUGPOSTTRANS
a2f18f
+   output2=${DEBUGPOSTTRANS}.upgrade
a2f18f
 fi
a2f18f
-echo looking for services in %{_sysconfdir}/systemd/system/%{groupname}.wants/* >> $output 2>&1 || :
a2f18f
-for service in %{_sysconfdir}/systemd/system/%{groupname}.wants/* ; do
a2f18f
-    if [ ! -f "$service" ] ; then continue ; fi # in case nothing matches
a2f18f
-    inst=`echo $service | sed -e 's,%{_sysconfdir}/systemd/system/%{groupname}.wants/,,'`
a2f18f
-    echo found instance $inst - getting status >> $output 2>&1 || :
a2f18f
+echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || :
a2f18f
+instbase="%{_sysconfdir}/%{pkgname}"
a2f18f
+for dir in $instbase/slapd-* ; do
a2f18f
+    echo dir = $dir >> $output 2>&1 || :
a2f18f
+    if [ ! -d "$dir" ] ; then continue ; fi
a2f18f
+    case "$dir" in *.removed) continue ;; esac
a2f18f
+    basename=`basename $dir`
a2f18f
+    inst="%{pkgname}@`echo $basename | sed -e 's/slapd-//g'`"
a2f18f
+    echo found instance $inst - getting status  >> $output 2>&1 || :
a2f18f
     if /bin/systemctl -q is-active $inst ; then
a2f18f
        echo instance $inst is running >> $output 2>&1 || :
a2f18f
        instances="$instances $inst"
a2f18f
@@ -290,9 +296,9 @@ echo remove pid files . . . >> $output 2>&1 || :
a2f18f
 echo upgrading instances . . . >> $output 2>&1 || :
a2f18f
 DEBUGPOSTSETUPOPT=`/usr/bin/echo $DEBUGPOSTSETUP | /usr/bin/sed -e "s/[^d]//g"`
a2f18f
 if [ -n "$DEBUGPOSTSETUPOPT" ] ; then
a2f18f
-    %{_sbindir}/setup-ds.pl -l $output -$DEBUGPOSTSETUPOPT -u -s General.UpdateMode=offline >> $output 2>&1 || :
a2f18f
+    %{_sbindir}/setup-ds.pl -l $output2 -$DEBUGPOSTSETUPOPT -u -s General.UpdateMode=offline >> $output 2>&1 || :
a2f18f
 else
a2f18f
-    %{_sbindir}/setup-ds.pl -l $output -u -s General.UpdateMode=offline >> $output 2>&1 || :
a2f18f
+    %{_sbindir}/setup-ds.pl -l $output2 -u -s General.UpdateMode=offline >> $output 2>&1 || :
a2f18f
 fi
a2f18f
 
a2f18f
 # restart instances that require it
a2f18f
-- 
a2f18f
1.9.3
a2f18f