ldap/admin/src/scripts/DSMigration.pm.in | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
New commits:
commit 8aee2bd4357d2f87f870c694f9456b293b42b51c
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Jan 13 10:23:24 2011 -0800
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.
diff --git a/ldap/admin/src/scripts/DSMigration.pm.in
b/ldap/admin/src/scripts/DSMigration.pm.in
index 1bd594c..5434075 100644
--- a/ldap/admin/src/scripts/DSMigration.pm.in
+++ b/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;