Return 0 on uninstall when on_master for case of not installed

This is to suppress the spurious error message:

The ipa-client-install command failed.

when the client is not configured.

This is managed by allowing a ScriptError to return SUCCESS (0)
and have this ignored in log_failure().

https://pagure.io/freeipa/issue/7836

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Rob Crittenden authored and Florence Blanc-Renaud committed 2019-06-07 11:24:45 +02:00
1 parent 1284bf1588
commit c1c50650a7
2 files changed
+11 -2

No files matched your search

+6 -1
View File
@@ -279,7 +279,7 @@ class AdminTool:
"""Given an exception, return a message (or None) and process exit code
"""
if isinstance(exception, ScriptError):
return exception.msg, exception.rval or 1
return exception.msg, exception.rval
elif isinstance(exception, SystemExit):
if isinstance(exception.code, int):
return None, exception.code
@@ -307,6 +307,11 @@ class AdminTool:
self.command_name, type(exception).__name__, exception)
if error_message:
logger.error('%s', error_message)
if return_value == 0:
# A script may raise an exception but still want quit gracefully,
# like the case of ipa-client-install called from
# ipa-server-install.
return
message = "The %s command failed." % self.command_name
if self.log_file_name and return_value != 2:
# magic value because this is common between server and client