Bug 1510374 - The `raw_connect` method of the RHV provider doesn't throw `Miq*` exceptions
Summary: The `raw_connect` method of the RHV provider doesn't throw `Miq*` exceptions
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: unspecified
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: GA
: 5.10.0
Assignee: Boriso
QA Contact: Angelina Vasileva
URL:
Whiteboard:
Depends On:
Blocks: 1519815
TreeView+ depends on / blocked
 
Reported: 2017-11-07 09:48 UTC by Juan Hernández
Modified: 2019-07-31 08:23 UTC (History)
6 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1519815 (view as bug list)
Environment:
Last Closed: 2018-06-21 20:44:44 UTC
Category: ---
Cloudforms Team: RHEVM
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Juan Hernández 2017-11-07 09:48:08 UTC
The `raw_connect` method of providers is intended to check connection and authentication details. In particular it is called from the UI when the user clicks the `Validate` button in the form used to add a new provider.

This method should report errors throwing instances of `MiqEVMLoginError`, `MiqInvalidCredentialsError`, etc. But the RHV provider only throws this kinds of errors when it uses version 3 of the API. The reason is that the code that throws those exceptions only catches the exceptions that are generated by the old `ovirt` gem, used for version 3 of the API, and not the ones that are generated by the new `ovirt-engine-sdk` gem, used for version 4 of the API. For example:

  def verify_credentials_for_rhevm(options = {})
    with_provider_connection(options) { |connection| connection.test(true) }
  rescue SocketError, Errno::EHOSTUNREACH, Errno::ENETUNREACH
    _log.warn($ERROR_INFO)
    raise MiqException::MiqUnreachableError, $ERROR_INFO
  rescue MiqException::MiqUnreachableError => e
    raise e
  rescue RestClient::Unauthorized
    raise MiqException::MiqInvalidCredentialsError, "Incorrect user name or password."
  rescue
    _log.error("Error while verifying credentials #{$ERROR_INFO}")
    raise MiqException::MiqEVMLoginError, $ERROR_INFO
  end

The result is not very serious, as the ManageIQ core catches all exceptions, and displays the message to the user anyhow. But it would be more consistent if it throws these standard exceptions: the messages displayed to the user would be the same when using version 3 and version 4 of the API.


Note You need to log in before you can comment on or make changes to this bug.