Jake Hunsaker has uploaded a new change for review. Change subject: error handling: Provide more informative error messages ......................................................................
error handling: Provide more informative error messages This patch provides more informative error messages for common failures for request and connection errors. In some cases a ConnectionError can represent either an inability to hit the API or we can hit the API but verification checks fail. This is significant and should be reported. Change-Id: I969f75ce9402df4b42f45c7293266bf60acc59e3 Bug-Url: https://bugzilla.redhat.com/1182344 Signed-off-by: Jake Hunsaker <jhuns...@redhat.com> --- M src/__main__.py 1 file changed, 82 insertions(+), 19 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-iso-uploader refs/changes/29/36929/1 diff --git a/src/__main__.py b/src/__main__.py index 841d81c..245e2c6 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -526,26 +526,88 @@ ) return False except RequestError as re: - logging.error( - _( - "Unable to connect to REST API at {url}\n" - "Reason: {reason}" - ).format( - url=url, - reason=re.reason, - ), - ) - return False - except ConnectionError: - logging.error( - _( - "Problem connecting to the REST API at {url}\n" - "Is the service available and does the CA certificate " - "exist?" - ).format( - url=url, + if re.status == 401: + logging.error( + _( + "Unable to connect to REST API at {url}\n" + "Host returned a 401 Unauthorized error. " + "Please check the engine certificates." + ).format( + url = url + ) ) - ) + elif re.status == 503: + logging.error( + _( + "Unable to connect to REST API at {url}\n" + "Host returned a 503 Service Unavailable error.\n" + "Please ensure the engine is running and " + "the webUI is accessible." + ).format( + url = url + ) + ) + else: + logging.error( + _( + "Unable to connect to REST API at {url}\n" + "Reason: {reason}" + ).format( + url = url, + reason = re.reason + ) + ) + return False + except ConnectionError as e: + if "[Errno 1]" in e.args[0]: + logging.error( + _( + "Can connect to the REST API however " + "CA verification failed.\nPlease check " + "the CA or use the \'insecure\' option." + ) + ) + elif "[Errno -2]" in e.args[0]: + logging.error( + _( + "Unable to connect to the REST API " + "at {url} (unknown host).\nPlease ensure that " + "the engine's FQDN is set correctly in " + "/etc/ovirt-engine/isouploader.conf.d/10-engine-setup.conf " + "and is resolvable." + ).format( + url = url + ) + ) + elif "[Errno 111]" in e.args[0]: + logging.error( + _( + "Unable to connect to the REST API. " + "The connection was refused by the host at " + "{url}.\nPlease ensure that nothing is " + "blocking access to the service port." + ).format( + url = url + ) + ) + elif "[Errno 185090050]" in e.args[0]: + logging.error( + _( + "Can connect to the REST API however " + "the CA could not be loaded for verification. " + "\nPlease check that the CA exists or use " + "the \'insecure\' option." + ) + ) + else: + logging.error( + _( + "Problem connecting to the REST API.\n" + "Message: {err}" + ).format( + err = e.args[0] + ) + ) return False except NoCertificatesError: logging.error( @@ -559,6 +621,7 @@ ) return False except Exception as e: + logging.error( _( "Unable to connect to REST API at {url}\n" -- To view, visit http://gerrit.ovirt.org/36929 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I969f75ce9402df4b42f45c7293266bf60acc59e3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-iso-uploader Gerrit-Branch: master Gerrit-Owner: Jake Hunsaker <jhuns...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches