Skip to content

Commit

Permalink
Return 0 on uninstall when on_master for case of not installed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Florence Blanc-Renaud <[email protected]>
  • Loading branch information
rcritten authored and flo-renaud committed Jun 7, 2019
1 parent 1284bf1 commit c1c5065
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ipaclient/install/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3175,9 +3175,13 @@ def uninstall_check(options):
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)

if not is_ipa_client_installed(fstore):
if options.on_master:
rval = SUCCESS
else:
rval = CLIENT_NOT_CONFIGURED
raise ScriptError(
"IPA client is not configured on this system.",
rval=CLIENT_NOT_CONFIGURED)
rval=rval)

server_fstore = sysrestore.FileStore(paths.SYSRESTORE)
if server_fstore.has_files() and not options.on_master:
Expand Down
7 changes: 6 additions & 1 deletion ipapython/admintool.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def handle_error(self, exception):
"""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
Expand Down Expand Up @@ -307,6 +307,11 @@ def log_failure(self, error_message, return_value, exception, backtrace):
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
Expand Down

0 comments on commit c1c5065

Please sign in to comment.