Ver Fonte

Ticket #48243 - replica upgrade failed in starting dirsrv service due to upgrade scripts did not run

Description: In the upgrade process, there is a combination of requirements:
 . the server is running.
 . the server instance service is disabled.
 . upgrade scripts are expected to run against the instance.
 . the server is restarted once the upgrade is done.
 . the server instance service remains disabled.
To fulfill the requirements,
 . spec file is modified to enumerate slapd dir (except .remove) in the
   /etc/dirsrv for getting the server instance.
 . Start/Update perl scripts are modified not to create a symlink in
   /etc/systemd/system/dirsrv.target.wants for the upgrade case, which
   means the service remains disabled.

https://fedorahosted.org/389/ticket/48243

Reviewed by [email protected] (Thank you, Mark!!)
Noriko Hosoi há 10 anos atrás
pai
commit
29c09a5bcc

+ 4 - 3
ldap/admin/src/scripts/DSCreate.pm.in

@@ -1098,6 +1098,7 @@ sub updateTmpfilesDotD {
 }
 
 sub updateSystemD {
+    my $noservicelink = shift;
     my $inf = shift;
     my $unitdir = "@systemdsystemunitdir@";
     my $confbasedir = "@systemdsystemconfdir@";
@@ -1129,7 +1130,7 @@ sub updateSystemD {
             next;
         } else {
             my $servicelink = "$confdir/$pkgname\@$inst.service";
-            if (! -l $servicelink) {
+            if (! -l $servicelink && ! $noservicelink) {
                 if (!symlink($servicefile, $servicelink)) {
                     debug(1, "error updating link $servicelink to $servicefile - $!\n");
                     push @errs, [ 'error_linking_file', $servicefile, $servicelink, $! ];
@@ -1216,7 +1217,7 @@ sub createDSInstance {
         return @errs;
     }
 
-    if (@errs = updateSystemD($inf)) {
+    if (@errs = updateSystemD(0, $inf)) {
         return @errs;
     }
 
@@ -1452,7 +1453,7 @@ sub removeDSInstance {
     }
 
     # update systemd files
-    push @errs, updateSystemD();
+    push @errs, updateSystemD(0);
     
     # if we got here, report success
     if (@errs) {

+ 1 - 1
ldap/admin/src/scripts/DSMigration.pm.in

@@ -1132,7 +1132,7 @@ sub migrateDS {
         }
 
 	# do the systemd stuff
-        @errs = DSCreate::updateSystemD($inf);
+        @errs = DSCreate::updateSystemD(0, $inf);
         if (@errs) {
             $mig->msg(@errs);
             goto cleanup;

+ 1 - 1
ldap/admin/src/scripts/DSUpdate.pm.in

@@ -408,7 +408,7 @@ sub updateDSInstance {
 
     push @errs, updateTmpfilesDotD($inf);
 
-    push @errs, updateSystemD($inf);
+    push @errs, updateSystemD(1, $inf);
 
     return @errs;
 }

+ 13 - 7
rpm/389-ds-base.spec.in

@@ -263,6 +263,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %post
 output=/dev/null
+output2=/dev/null
 %systemd_post %{pkgname}-snmp.service
 # reload to pick up any changes to systemd files
 /bin/systemctl daemon-reload >$output 2>&1 || :
@@ -275,12 +276,17 @@ instances="" # instances that require a restart after upgrade
 ninst=0 # number of instances found in total
 if [ -n "$DEBUGPOSTTRANS" ] ; then
    output=$DEBUGPOSTTRANS
+   output2=${DEBUGPOSTTRANS}.upgrade
 fi
-echo looking for services in %{_sysconfdir}/systemd/system/%{groupname}.wants/* >> $output 2>&1 || :
-for service in %{_sysconfdir}/systemd/system/%{groupname}.wants/* ; do
-    if [ ! -f "$service" ] ; then continue ; fi # in case nothing matches
-    inst=`echo $service | sed -e 's,%{_sysconfdir}/systemd/system/%{groupname}.wants/,,'`
-    echo found instance $inst - getting status >> $output 2>&1 || :
+echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || :
+instbase="%{_sysconfdir}/%{pkgname}"
+for dir in $instbase/slapd-* ; do
+    echo dir = $dir >> $output 2>&1 || :
+    if [ ! -d "$dir" ] ; then continue ; fi
+    case "$dir" in *.removed) continue ;; esac
+    basename=`basename $dir`
+    inst="%{pkgname}@`echo $basename | sed -e 's/slapd-//g'`"
+    echo found instance $inst - getting status  >> $output 2>&1 || :
     if /bin/systemctl -q is-active $inst ; then
        echo instance $inst is running >> $output 2>&1 || :
        instances="$instances $inst"
@@ -305,9 +311,9 @@ echo remove pid files . . . >> $output 2>&1 || :
 echo upgrading instances . . . >> $output 2>&1 || :
 DEBUGPOSTSETUPOPT=`/usr/bin/echo $DEBUGPOSTSETUP | /usr/bin/sed -e "s/[^d]//g"`
 if [ -n "$DEBUGPOSTSETUPOPT" ] ; then
-    %{_sbindir}/setup-ds.pl -l $output -$DEBUGPOSTSETUPOPT -u -s General.UpdateMode=offline >> $output 2>&1 || :
+    %{_sbindir}/setup-ds.pl -l $output2 -$DEBUGPOSTSETUPOPT -u -s General.UpdateMode=offline >> $output 2>&1 || :
 else
-    %{_sbindir}/setup-ds.pl -l $output -u -s General.UpdateMode=offline >> $output 2>&1 || :
+    %{_sbindir}/setup-ds.pl -l $output2 -u -s General.UpdateMode=offline >> $output 2>&1 || :
 fi
 
 # restart instances that require it