فهرست منبع

Bug 470576 - Migration could do addition checks before commiting actions

https://bugzilla.redhat.com/show_bug.cgi?id=470576

The migration script can fail for various reasons leaving the server
in an inconsistent state. Sometimes a manual cleanup is required before
the script can be run again. Since there is no easy way to revert the
changes done to the server, the script has been modified such that it
removes the server that fails to be migrated. Once the cause of the
failure has been resolved the script can be run again.
Nathan Kinder 15 سال پیش
والد
کامیت
8aee2bd435
1فایلهای تغییر یافته به همراه16 افزوده شده و 5 حذف شده
  1. 16 5
      ldap/admin/src/scripts/DSMigration.pm.in

+ 16 - 5
ldap/admin/src/scripts/DSMigration.pm.in

@@ -1124,7 +1124,7 @@ sub migrateDS {
         if (@errs) {
             $mig->msg(@errs);
             $mig->msg($FATAL, 'error_creating_dsinstance', $inst);
-            return 0;
+            goto cleanup;
         } else {
             $mig->msg('created_dsinstance', $inst);
         }
@@ -1132,13 +1132,13 @@ sub migrateDS {
         my $src = new FileConn("$oldconfigdir/dse.ldif", 1); # read-only
         if (!$src) {
             $mig->msg($FATAL, 'error_opening_dseldif', "$oldconfigdir/dse.ldif", $!);
-            return 0;
+            goto cleanup;
         }
         my $dest = new FileConn("$mig->{configdir}/$inst/dse.ldif");
         if (!$dest) {
             $src->close();
             $mig->msg($FATAL, 'error_opening_dseldif', "$mig->{configdir}/$inst/dse.ldif", $!);
-            return 0;
+            goto cleanup;
         }
 
         @errs = migrateDSInstance($mig, $inst, $src, $dest);
@@ -1146,7 +1146,7 @@ sub migrateDS {
         $dest->close();
         if (@errs) {
             $mig->msg(@errs);
-            return 0;
+            goto cleanup;
         }
 
 	# ensure any selinux relabeling gets done if needed
@@ -1157,9 +1157,20 @@ sub migrateDS {
             $inf->{slapd}->{start_server} = 1;
             if (@errs = DSCreate::startServer($inf)) {
                 $mig->msg(@errs);
-                return 0;
+                goto cleanup;
             }
         }
+
+        next;
+
+cleanup:
+        if (-d "$mig->{configdir}/$inst") {
+            @errs = removeDSInstance($inf->{slapd}->{ServerIdentifier}, 1);
+            if (@errs) {
+                $mig->msg(@errs);
+            }
+        }
+        return 0;
     }
 
     return 1;