ldap/admin/src/scripts/52updateAESplugin.pl | 4 +++-
ldap/admin/src/scripts/DSUpdate.pm.in | 27 +++++++++++++++++++++++----
ldap/admin/src/scripts/setup-ds.res.in | 1 +
3 files changed, 27 insertions(+), 5 deletions(-)
New commits:
commit ac4309050fed643e962b21faa2cd76f6acd4fcf8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jun 19 16:22:46 2015 -0400
Ticket 47878 - Improve setup-ds update logging
Bug Description: If updating several instances using the --force option,
and a particular instance fails to update, the script
reports total failure even though the other instances
were successfully updated.
Fix Description: Improved the logging to say that the update was successful,
and also clearly log the instances that were not updated.
Also removed an unnecessary warning from 52updateAESplugin.pl
https://fedorahosted.org/389/ticket/47878
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/admin/src/scripts/52updateAESplugin.pl
b/ldap/admin/src/scripts/52updateAESplugin.pl
index 6a8a885..ae258b6 100644
--- a/ldap/admin/src/scripts/52updateAESplugin.pl
+++ b/ldap/admin/src/scripts/52updateAESplugin.pl
@@ -6,6 +6,8 @@ use File::Basename;
use File::Copy;
use DSUtil qw(debug serverIsRunning);
+no warnings 'experimental::smartmatch';
+
#
# Check if there is a DES plugin and make sure the AES plugin contains the same
attributes
#
@@ -53,7 +55,7 @@ sub runinst {
if($val eq ""){
last;
}
- if(!($val ~~ @attrs) ){
+ if(!($val ~~ @attrs) ){ # smartmatch
$attrs_to_add[$des_count] = $val;
$des_count++;
}
diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in
b/ldap/admin/src/scripts/DSUpdate.pm.in
index 208edfe..6660f5c 100644
--- a/ldap/admin/src/scripts/DSUpdate.pm.in
+++ b/ldap/admin/src/scripts/DSUpdate.pm.in
@@ -270,17 +270,36 @@ sub updateDS {
}
# update each instance
- for my $inst ($setup->getDirServers()) {
+ my @instances = $setup->getDirServers();
+ my $inst_count = @instances;
+ my @failed_instances = ();
+ my $failed_count = 0;
+ for my $inst (@instances) {
+ debug(0, "Updating instance ($inst)...\n");
my @localerrs = updateDSInstance($inst, $inf, $setup->{configdir}, \@updates,
$force);
if (@localerrs) {
# push array here because localerrs will likely be an array of
# array refs already
- push @errs, @localerrs;
- if (!$force) {
+ $failed_count++;
+ if (!$force || $inst_count == 1) {
+ push @errs, @localerrs;
return @errs;
}
+ push @failed_instances, $inst;
+ debug(0, "Failed to update instance ($inst):\n--->
@localerrs\n");
+ } else {
+ debug(0, "Successfully updated instance ($inst).\n");
}
}
+ if($failed_count && $failed_count == $inst_count){
+ push @errs, ('error_update_all');
+ return @errs;
+ }
+ if (@failed_instances){
+ # list all the instances that were not updated
+ debug(0, "The following instances were not updated: (@failed_instances).
");
+ debug(0, "After fixing the problems you will need to rerun the setup
script\n");
+ }
# run post-update hooks
for my $upd (@updates) {
@@ -344,7 +363,7 @@ sub updateDSInstance {
$conn = new Mozilla::LDAP::Conn({ host => $host, port => $port, bind =>
$binddn,
pswd => $bindpw, cert => $certdir,
starttls => 1 });
if (!$conn) {
- debug(0, "Could not open TLS connection to $host:$port - trying regular
connection\n");
+ debug(1, "Could not open TLS connection to $host:$port - trying regular
connection\n");
$conn = new Mozilla::LDAP::Conn({ host => $host, port => $port, bind
=> $binddn,
pswd => $bindpw });
}
diff --git a/ldap/admin/src/scripts/setup-ds.res.in
b/ldap/admin/src/scripts/setup-ds.res.in
index f8157af..011bf36 100644
--- a/ldap/admin/src/scripts/setup-ds.res.in
+++ b/ldap/admin/src/scripts/setup-ds.res.in
@@ -206,3 +206,4 @@ error_running_command = Error: command '%s' failed - output
[%s] error [%s]
error_opening_file = Opening file '%s' failed. Error: %s\n
error_format_error = '%s' has invalid format.\n
error_update_not_offline = Error: offline mode selected but the server [%s] is still
running.\n
+error_update_all = Failed to update all the Directory Server instances.\n